Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3205 Widoki

good day everyone,


I a custom module we want to add field inheriting a class, however we don't find the proper way to xpath to it.  we tried both ways and got error "xpath cannot be located in parent view"


<template id="products_item_inters" inherit_id="website_sale.products_item">



 <!--<xpath expr="//div[hasclass('p-2 o_wsale_product_information_text')]" position="inside"> -->



 <xpath expr="//div[@id='p-2 o_wsale_product_information_text']" position="inside">



  <h6 class="o_wsale_products_item_title mb-1">



   <a class="text-primary text-decoration-none" itemprop="default_code" t-att-href="product_href" t-att-content="product.default_code" t-field="product.default_code" />



  </h6>



 </xpath>



</template>
















Awatar
Odrzuć
Najlepsza odpowiedź

I can't post code :(


Use for example H6-Title-Element o_wsale_products_item_title inside that div for xpath and work with position after, before or replace instead of inside.


Hope that helps

Awatar
Odrzuć
Autor

Thanks!

Najlepsza odpowiedź

Dear Christian Kubicki and Avash,
I can not write comment, thats why writing as an answer. and code is in comments. Sorry.

Me too have same issue i want to replace website_sale.products_item template last span but its keep on giving me "Extra content at the end of the document" Error.
Could someone let me know what mistake am i doing here.
Thanks.

Awatar
Odrzuć

<template id="products_item_intert" inherit_id="website_sale.products_item">
<xpath expr="//span[last()]" position="replace">
<t t-set="pqty" t-value='int(product.qty_available)'/>
<span t-out="str((td_product['ribbon']['html'] or '') + ' ' + str(pqty) or '')" t-attf-class="o_ribbon #{bg_class}" t-attf-style="#{text_color and ('color: %s; ' % text_color)}#{bg_color and 'background-color:' + bg_color}" />
</xpath>
</template>​

Powiązane posty Odpowiedzi Widoki Czynność
0
sie 24
1489
1
cze 23
3811
0
cze 23
1689
0
maj 22
2428
0
maj 17
3652