Home > database >  Menu and Sumenu in odoo15
Menu and Sumenu in odoo15

Time:12-29

I am trying to add a submenu in a menu in odoo-15 website in xml part, so for that in xml i have written:

<record id="menu_solutions" model="website.menu">
    <field name="name">Solutions</field>
    <field name="parent_id" ref="website.main_menu"/>
    <field name="sequence" type="int">20</field>
</record>
<record id="menu_submenu_erp" model="website.menu">
    <field name="name">ERP</field>
    <field name="url">/shop</field>
    <field name="parent_id" ref="website_main_menu.menu_solutions"/>
    <field name="sequence" type="int">20</field>
</record>

i have researched in google for adding sub-menu and i have got some results and i have tried the same still i am getting 2 menus instead of a menu and a sub-menu of that menu

please let me know if still my question is unclear, any help will be appreciated, thanks

CodePudding user response:

You need to check the create function of the website menu, it is overriden to set the parent menu to the website top menu (Top Menu for Website 1) if the website_id field value is not provided.

You can remove the parent menu from Solutions and set the website_id field value in the ERP menu.

Example:

<record id="menu_solutions" model="website.menu">
    <field name="name">Solutions</field>
    <field name="sequence" type="int">20</field>
</record>

<record id="menu_submenu_erp" model="website.menu">
    <field name="name">ERP</field>
    <field name="url">/shop</field>
    <field name="website_id" ref="website.default_website"/>
    <field name="parent_id" ref="menu_solutions"/>
    <field name="sequence" type="int">20</field>
</record>
  • Related