Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
14226 Ansichten

Hello,

I am trying to add existing division of Odoo product template in a new division. for that, I can do the "replace" of the whole division. and add my custom division.
for example, here is default Odoo template section with the div.

<section t-attf-class="container mt8 oe_website_sale" id="product_detail">
    <div class="row" id="odoo_default_row">
    </div>
</section>


and I wanted to add odoo_default_row div in my custom div element. like

<section t-attf-class="container mt8 oe_website_sale" id="product_detail">
    <div id="my_custom_div">
        <div class="row" id="odoo_default_row">
        </div>
    </div>
</section>


what is the best way to add existing division in the custom division despite using xpath replace?

Avatar
Verwerfen
Beste Antwort

Hi 


Try this 

<template id="website_sale" inherit_id="website.id_template" name="Name for your template "> 
 <xpath expr="//div[@id='odoo_default_row']" position="replace">

<div id="my_custom_div">
 <div class="row" id="odoo_default_row">
</div>
</div>


</xpath>
</template>



Avatar
Verwerfen
Beste Antwort

the better answer to the accepted one should be

create your custom div on the same hierarchy level as the existing field, then move your div inside it

the accepted answer is ok if you div is simple, but if you have a complex definition with domain definitions, readonly / visibility definitions and such you can keep your existing definition with my answer

<template id="website_sale" inherit_id="website.id_template" name="Name for your template "> 
 <xpath expr="//div[@id='odoo_default_row']" position="before">
<div id="my_custom_div">
</div>
</xpath>
 <xpath expr="//div[@id='my_custom_div']" position="inside">
<xpath expr="//div[@id='odoo_default_row']" position="move"/>
</xpath>
</template>


Avatar
Verwerfen
Beste Antwort

You can replace a default element with a custom element or you can add a custom element to an default element. If you want to add a default element to a custom element, then you have to replace the default element with an element, which contains your custom element and the default element.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Mai 25
432
1
Dez. 24
1923
1
Juli 21
8202
1
Aug. 24
1395
1
Juni 24
4078