Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
167 Prikazi

I have this code from a custom module that I want to add as an inherited view. However, the view I want to assign it to is website.homepage. When I do it this way, a different tree is created with the inherited view instead of assigning it to the already existing one. Any idea what might be happening?

<odoo>

  <data>

    <record id="alx_al_website" model="ir.ui.view">

      <field name="name">(CUSTOM) - landing page</field>

      <field name="type">qweb</field>

      <field name="inherit_id" ref="website.homepage"/>

      <field name="priority" eval="1000"/>

      <field name="website_id" ref="website.default_website"/>

      <field name="arch" type="xml">

        <xpath expr="//div[@id='wrap']" position="replace">

          <div><p>hello world</p></div>

        </xpath>

      </field>

    </record>

  </data>

</odoo>

Avatar
Opusti
Best Answer

Hi,


Try the following,

<odoo>

  <data>

    <record id="alx_al_website" model="ir.ui.view">

      <field name="name">(CUSTOM) - landing page</field>

      <field name="type">qweb</field>

      <field name="inherit_id" ref="website.homepage"/>

      <field name="priority" eval="1000"/>

      <field name="arch" type="xml">

        <xpath expr="//div[@id='wrap']" position="replace">

          <div><p>hello world</p></div>

        </xpath>

      </field>

    </record>

  </data>

</odoo>


When you create an inherited view in Odoo:

  • If you don’t set website_id, the view applies globally to all websites. Updating the module will always refresh it everywhere, including new websites.
  • If you set website_id, the view is tied only to that website. Updates to the module will refresh it only for that site, and new websites won’t automatically get the changes.

Best practice:

Use global inheritance if you want one universal homepage design, and add website_id only if you want different designs per website.


Hope it helps

Avatar
Opusti
Best Answer

Hi Diego,

What’s happening is due to how website-specific views work in Odoo. When you include a <field name="website_id" .../> in your inherited view, Odoo doesn’t just extend the existing website.homepage — instead, it creates a website-restricted variant of the homepage. That’s why you see a new view “tree” instead of your code extending the original one.

If you want your changes to apply globally (for all websites), simply remove the website_id field:

<record id="alx_al_website" model="ir.ui.view"> <field name="name">(CUSTOM) - landing page</field> <field name="type">qweb</field> <field name="inherit_id" ref="website.homepage"/> <field name="arch" type="xml"> <xpath expr="//div[@id='wrap']" position="replace"> <div><p>hello world</p></div> </xpath> </field> </record>

If you really need it to apply only to a specific website, then keeping website_id is correct, but in that case Odoo will always generate a new branch of the view for that website — that’s the expected behavior.

Hope this helps!

Avatar
Opusti
Avtor

Thanks for the answer, however I have a question if a website already exists, this template only applies to new sites, but if I update the module with a new view The inherited view logically will not be updated and will only apply to sites closed later to the installation of the module, not to those previously created, any strategy that you can propose to me?

Related Posts Odgovori Prikazi Aktivnost
1
jun. 25
2196
2
jun. 25
934
0
feb. 25
1467
3
okt. 24
1963
0
jun. 24
1465