31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
|
|
from odoo import models, fields
|
|
|
|
|
|
class MenuInherit(models.Model):
|
|
_inherit = 'ir.ui.menu'
|
|
|
|
is_phone = fields.Boolean("是否手机显示", default=True)
|
|
|
|
def load_web_menus(self, debug):
|
|
""" Loads all menu items (all applications and their sub-menus) and
|
|
processes them to be used by the webclient. Mainly, it associates with
|
|
each application (top level menu) the action of its first child menu
|
|
that is associated with an action (recursively), i.e. with the action
|
|
to execute when the opening the app.
|
|
|
|
:return: the menus (including the images in Base64)
|
|
"""
|
|
web_menus = {}
|
|
menus = self.search_read([], fields=['id', 'is_phone'])
|
|
menus_dict = {m['id']: m for m in menus}
|
|
|
|
old_menus = super().load_web_menus(debug)
|
|
|
|
for menu in old_menus.values():
|
|
|
|
menu['is_phone'] = menus_dict[menu['id']]['is_phone'] if menu['id'] != 'root' else True
|
|
web_menus[menu['id']] = menu
|
|
|
|
return web_menus
|