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

I am using odoo v12. If I want to change menu name or hide that menu to display in website. How I will do this?I have tried to create a function and through that try to change menu name but I of default website this is not work.

for ex. if need to change shop menu to "Products" and  hide blog menu from website.
I have tried following code, but It is only work for default menu not for website 1 menu.
_inherit = 'website.menu'

    @api.model
    def update_menu(self):
        self.env.ref('website_sale.menu_shop').write({'name': 'Products'}) //It is change default main menu
        return True
Any help?


Awatar
Odrzuć
Najlepsza odpowiedź

I am not experienced with web, but on my website, I go in Edit mode. Click on an menu item, and the Edit menu option opens.   Add, Delete, change name, change action. It is all there.

Awatar
Odrzuć
Autor

Ya, we can add, Delete, change name, change action.But we can not hide menu from editor.

And I want to change and hide menu through code.

If I say it differently: You want a different top menu on some pages. That is more tricky, and you will need to modify the code.

Najlepsza odpowiedź

Hi Maitree Trivedi,

You can modify the existing website menu by inheriting the website template and modify it as shown below

        <template id="product_item_hide_no_price" inherit_id="website_sale.products_item">
            <xpath expr="//div[hasclass('product_price')]/b" position="attributes">
                <attribute name="t-if">product.price &gt; 0</attribute>
            </xpath>
        </template>
use the xpath tag to select and alter elements from the modified view
Awatar
Odrzuć
Autor

sorry I didn't get you. Which website template you want me to inherit?

The template which you want to change the menu name.. or share me for which menu you need to change the menu name.

Autor

As I explain in my question, I want to change shop menu to "Products" and hide blog menu from website.

Powiązane posty Odpowiedzi Widoki Czynność
1
cze 24
1522
1
lip 19
3336
2
lip 25
6033
1
lip 25
517
2
cze 25
2159