İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
3142 Görünümler

hey guys! I have a problem inheriting owl template and an qweb from 'mrp_workorder' module in my custom module... 

this is my code:

import { registry } from "@web/core/registry";

import { MrpDisplayRecord } from "@mrp_workorder/mrp_display/mrp_display_record";

export class MrpDisplayRecordInherited extends MrpDisplayRecord {    

// New Inherit template    

static template = "mrp_workorder.MrpDisplayRecordInherited";

    setup() {       

​// call original setup        

​super.setup();

        // New field        

​const numOt = this.props.production?.data?.num_ot || null;        

​this.numOt = numOt;        

​console.log("numero de ot:", numOt);    

}}

// registry 

registry.category("components").add("mrp_display_record", MrpDisplayRecordInherited);

num_ot is the field I need to add... so it can be shown in the qweb
this is the original one...

< templates xml:space="preserve">    

< t t-name="mrp_workorder.MrpDisplayRecordInherited">    

< t t-call="mrp_workorder.MrpDisplayRecord"/>  

     

  HERE SHOULD GO NEW DIV    

 < /t>   

 < /t>

< /templates> 



but nothing happenss.... 

please guys is someone knows something I will be really grateful for the help!

           



Avatar
Vazgeç
En İyi Yanıt

Try this in your template. This is to inherit the existing template and add your own div.


<t t-name="CUSTOM_MODULE_NAME.MrpDisplayRecordInherited" t-inherit="mrp_workorder.MrpDisplayRecord">
<xpath expr="//div[hasclass('o_finished_product')]/*" position="after">
<div class="CUSTOM_DIV_CLASS">
<span t-esc="num_ot"/></div>
        </xpath>
    </t>

       

           

Hope this helps!

Avatar
Vazgeç
En İyi Yanıt

I’m trying to customize the Optimize SEO page, specifically the website.TitleDescription section.

I found the original template as follows:

<t t-name="website.TitleDescription">
<section>
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label for="website_meta_title">
Title <i class="fa fa-question-circle-o" title="The title will take a default value unless you specify one."/>
</label>
<input type="text" t-model="seoContext.title" t-att-disabled="!props.canEditTitle" class="form-control" placeholder="Keep empty to use default value" maxlength="70" size="70" t-ref="autofocus"/>
</div>
<div class="mb-3">
<label for="website_meta_description">
Description <i class="fa fa-question-circle-o" t-att-title="props.previewDescription"/>
</label>
<textarea t-model="seoContext.description" t-att-disabled="!props.canEditDescription" name="website_meta_description" placeholder="Keep empty to use default value" class="form-control"/>
<div t-if="descriptionWarning.length" class="alert alert-warning mt16 mb0 small">
<span t-esc="descriptionWarning"/>
</div>
</div>
<div class="mb-3" t-if='props.canEditUrl'>
<label for="website_seo_name">
Custom Url <i class="fa fa-question-circle-o" t-att-title="props.seoNameHelp" />
</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text seo_name_pre" t-esc="seoNamePre"/>
</div>
<input type="text" class="form-control" t-att-placeholder="props.seoNameDefault"
t-on-input="_updateInputValue" t-att-value="seoContext.seoName"/>
<div class="input-group-append" title="Unalterable unique identifier">
<span class="input-group-text seo_name_post" t-esc="seoNamePost"/>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card-header">Preview</div>
<div class="card mb0 p-0">
<div class="card-body">
<SEOPreview isIndexed="props.isIndexed" title="title" description="description" url="url"/>
</div>
</div>
</div>
</div>
</section>
</t>


I created an inherited template as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="custom_Optimize_seo.TitleDescriptionInherit" t-inherit="website.TitleDescription">
<xpath expr="//input[@t-model='seoContext.title']" position="after">
<div class="est_ccs">
<h1>Test</h1>
</div>
</xpath>
</t>
</templates>


And my manifest file looks like this:

'assets': {
'web.assets_frontend': [
# 'theme_vcs/static/src/scss/style.scss',
],
'web.assets_backend': [
# 'website/static/src/components/dialog/seo.xml',
'custom_Optimize_seo/static/src/xml/seo_template.xml',
],
},


However, it’s not working as expected.

Could you please help me check the code?
Thank you very much!

Avatar
Vazgeç
Üretici En İyi Yanıt

it helped!!! thankssssssssss 

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Tem 25
132
1
Mar 24
1447
0
Eki 22
1776
3
Eki 23
4902
1
Oca 25
1263