+1








0573acae23
This commit is the first phase of the conversion of the web/ JS codebase to the owl framework. The impact of this commit is two-fold. First, it rewrites the framework part of web with a new system of services and registries. Services allow to execute code (e.g. do rpcs, setup things) before launching the application. They can also expose an API to be used by other parts of the application (e.g. a notification service would expose a function to display notifications). Services are often a good extension point for external modules that want to execute code at webclient startup. Registries offer another way to extend the application. They provide well designed extension points to add elements/behaviors from the outside (for instance, to add a systray item, an error handler...). Second, this commit initiates the conversion of the webclient to owl with a top-down approach, around those notions of services and registries. The root of the web application is now an owl application. Among others, the WebClient, ActionManager, Navbar, UserMenu, DebugManager, Dialogs, services (e.g. notification, ajax...) have been converted to the new framework/architecture. Legacy views and client actions are still supported (and used). They will be converted in the next months, and at some point, the support will be dropped. Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Bruno Boi <boi@odoo.com> Co-authored-by: Géry Debongnie <ged@odoo.com> Co-authored-by: Samuel Degueldre <sad@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Simon Genin (ges) <ges@odoo.com> Co-authored-by: Francois (fge) <fge@odoo.com> Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com> Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
62 lines
2.3 KiB
Python
62 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models
|
|
|
|
|
|
class IrUiMenu(models.Model):
|
|
_inherit = "ir.ui.menu"
|
|
|
|
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)
|
|
"""
|
|
menus = self.load_menus(debug)
|
|
|
|
web_menus = {}
|
|
for menu in menus.values():
|
|
if not menu['id']:
|
|
# special root menu case
|
|
web_menus['root'] = {
|
|
"id": 'root',
|
|
"name": menu['name'],
|
|
"children": menu['children'],
|
|
"appID": False,
|
|
"xmlid": "",
|
|
"actionID": False,
|
|
"actionModel": False,
|
|
"webIcon": None,
|
|
"webIconData": None,
|
|
}
|
|
else:
|
|
action = menu['action']
|
|
|
|
if menu['id'] == menu['app_id']:
|
|
# if it's an app take action of first (sub)child having one defined
|
|
child = menu
|
|
while child and not action:
|
|
action = child['action']
|
|
child = menus[child['children'][0]] if child['children'] else False
|
|
|
|
action_model, action_id = action.split(',') if action else (False, False)
|
|
action_id = int(action_id) if action_id else False
|
|
|
|
web_menus[menu['id']] = {
|
|
"id": menu['id'],
|
|
"name": menu['name'],
|
|
"children": menu['children'],
|
|
"appID": menu['app_id'],
|
|
"xmlid": menu['xmlid'],
|
|
"actionID": action_id,
|
|
"actionModel": action_model,
|
|
"webIcon": menu['web_icon'],
|
|
"webIconData": menu['web_icon_data'],
|
|
}
|
|
|
|
return web_menus
|