I have Base theme called theme_test Here is the template code(this template is added in manifest's data).
<template id="product_catg_test" name="Product Category">
<t t-if="categories">
<code for print category>
</t>
</template>
So I have created an extended module called test_theme_extended and tried two inherit approach to replace the t-if condition
<template id="product_catg_test_extended" inherit_id="theme_test.product_catg_test" name="Test">
<xpath expr="//t[@t-if='categories']" position="replace"></xpath>
</template>
This first approach gives me an error
odoo.tools.convert.ParseError: "Element '' cannot be located in parent view
<t t-extend="theme_test.product_catg_test">
<t t-jquery="t[t-if='categories']" t-operation="replace"/>
</t>
This also not working.
I am thinking that the main view created from the theme and it has no external ID that's why I face this issue. But how can I inherit the base theme view in extended module?
If you are inheriting a theme it has to be from another theme, or use a record instead of template.
Defining a theme, as with a theme prefix and in the thema category

Since a module-theme creates the views in theme ir_ui_view and creates copies without XMLID in ir_ui_view
and a normal module creates the views in ir_ui_view
So if from a normal module (ir_ui_view) you want to modify a view-theme (theme_ir_ui_view) then literally it will not find the element because it is in another table
but if you still want to try you can do the inheritance in this way, inheriting the copies that do not have the XML so you have to do the inheritance by the key
<record id="product_catg_test_extended" model="ir.ui.view">
<field name="name">product_catg_test_extended</field>
<field name="inherit_id" search="[('key', '=', 'theme_test.product_catg_test')]"/>
<field name="type">qweb</field>
<field name="key">test_theme_extended.product_catg_test_extended</field>
<field name="arch" type="xml">
<xpath expr="//t[@t-if='categories']" position="replace"></xpath>
</field>
</record>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With