summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2017-05-22 17:28:54 +0200
committerYannick Tivisse <yti@odoo.com>2017-05-26 13:13:12 +0200
commit7e008469e4e5afe9b4c7151a4738240462359f98 (patch)
tree8d53bc636b26341afc4ac66616068afc273d9c8c
parent6110eb969da0397636a0aa4427b7bcc1334eee09 (diff)
[IMP] base: Always load menuitem xmlids on templates
PURPOSE ======= Currently we can choose to load the xmlid of a menuitem if web_tour is installed by setting the attribute `load_xmlid=True` on the view. This is strange for 2 reasons: - Searching all the ir.model.data on menuitems with load_xmlid=True to compute its xmlid, searching the related subtree on the returned structure of the method load_menus is quite complicated for the perfomance gain (if there is any perfomance gain to do it) - This is not working in community in frontend, as only the root menuitems are loaded, thus it is the `load_menus_root` instead of the `load_menus` that is called. This issue prevent a tour step to be displayed correctly on community and enterprise on a menuitem. SPECIFICATION ============= Remove all the `load_xmlid` attributes and the related mechanism and move it into base to always load the xmlids for all the menuitems. It won't bee to heavy as the result is cached. It's better the keep the current mechanism (Load the xmlids from ir.model.data and insert them into the tree) as we only make 1 search to the ir.model.data
-rw-r--r--addons/account_accountant/__manifest__.py1
-rw-r--r--addons/account_accountant/data/account_accountant_tour.xml10
-rw-r--r--addons/crm/views/crm_views.xml8
-rw-r--r--addons/hr_expense/__manifest__.py1
-rw-r--r--addons/hr_expense/views/hr_expense_views.xml2
-rw-r--r--addons/hr_expense/views/tour_views.xml7
-rw-r--r--addons/hr_recruitment/__manifest__.py1
-rw-r--r--addons/hr_recruitment/views/tour_views.xml7
-rw-r--r--addons/point_of_sale/views/point_of_sale_view.xml1
-rw-r--r--addons/project/__manifest__.py1
-rw-r--r--addons/project/views/tour_views.xml13
-rw-r--r--addons/sale_management/__manifest__.py1
-rw-r--r--addons/sale_management/data/sale_management_tour.xml13
-rw-r--r--addons/web_tour/models/__init__.py1
-rw-r--r--addons/web_tour/models/ir_ui_menu.py38
-rw-r--r--addons/website/views/website_navbar_templates.xml2
-rw-r--r--addons/website/views/website_views.xml1
-rw-r--r--odoo/addons/base/ir/ir_ui_menu.py29
-rw-r--r--odoo/import_xml.rng3
-rw-r--r--odoo/tools/convert.py2
20 files changed, 30 insertions, 112 deletions
diff --git a/addons/account_accountant/__manifest__.py b/addons/account_accountant/__manifest__.py
index 7f14d36e77b..f8af161bd47 100644
--- a/addons/account_accountant/__manifest__.py
+++ b/addons/account_accountant/__manifest__.py
@@ -17,7 +17,6 @@ It assigns manager and user access rights to the Administrator for the accountin
'depends': ['account', 'web_tour'],
'data': [
'data/account_accountant_data.xml',
- 'data/account_accountant_tour.xml',
'security/account_accountant_security.xml',
'views/account_accountant_templates.xml',
'views/res_config_view.xml',
diff --git a/addons/account_accountant/data/account_accountant_tour.xml b/addons/account_accountant/data/account_accountant_tour.xml
deleted file mode 100644
index 8b42e5e2a22..00000000000
--- a/addons/account_accountant/data/account_accountant_tour.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data>
- <!-- Make the xmlid of menus required by the Accounting tour available in webclient -->
- <record id="account.menu_finance" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="account.menu_finance_reports" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-</data>
diff --git a/addons/crm/views/crm_views.xml b/addons/crm/views/crm_views.xml
index d6b276ab6d4..1e4c12953c3 100644
--- a/addons/crm/views/crm_views.xml
+++ b/addons/crm/views/crm_views.xml
@@ -27,12 +27,4 @@
sequence="1"
groups="sales_team.group_sale_manager"/>
- <!-- Make the xmlid of menus required by the CRM tour available in webclient -->
- <record id="sales_team.menu_base_partner" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="base.menu_administration" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-
</odoo>
diff --git a/addons/hr_expense/__manifest__.py b/addons/hr_expense/__manifest__.py
index d41fb86a760..114200460a1 100644
--- a/addons/hr_expense/__manifest__.py
+++ b/addons/hr_expense/__manifest__.py
@@ -39,7 +39,6 @@ This module also uses analytic accounting and is compatible with the invoice on
'report/report_expense_sheet.xml',
'views/hr_dashboard.xml',
'views/hr_expense.xml',
- 'views/tour_views.xml',
'views/res_config_views.xml',
'data/web_planner_data.xml',
],
diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml
index d89340891d8..24a14c5e9f4 100644
--- a/addons/hr_expense/views/hr_expense_views.xml
+++ b/addons/hr_expense/views/hr_expense_views.xml
@@ -753,7 +753,7 @@ if records:
<menuitem id="menu_hr_expense_my_expenses" name="My Expenses" sequence="1" parent="menu_hr_expense_root" groups="base.group_user"/>
<menuitem id="menu_hr_expense_my_expenses_to_submit" name="Expenses to Submit" sequence="1" parent="menu_hr_expense_my_expenses" action="hr_expense_actions_my_unsubmitted"/>
<menuitem id="menu_hr_expense_my_expenses_refused" name="Refused Expenses" sequence="2" parent="menu_hr_expense_my_expenses" action="action_hr_expense_refused_expenses"/>
- <menuitem id="menu_hr_expense_sheet_my_reports" name="Expense Reports" sequence="3" parent="menu_hr_expense_my_expenses" action="action_hr_expense_sheet_my_all" load_xmlid="True"/>
+ <menuitem id="menu_hr_expense_sheet_my_reports" name="Expense Reports" sequence="3" parent="menu_hr_expense_my_expenses" action="action_hr_expense_sheet_my_all"/>
<menuitem id="menu_hr_expense_to_approve" name="To Approve" sequence="2" parent="menu_hr_expense_root" groups="hr_expense.group_hr_expense_user"/>
<menuitem id="menu_hr_expense_sheet_all_to_approve" name="Expense Reports To Approve" sequence="1" parent="menu_hr_expense_to_approve"
diff --git a/addons/hr_expense/views/tour_views.xml b/addons/hr_expense/views/tour_views.xml
deleted file mode 100644
index 9dc50422402..00000000000
--- a/addons/hr_expense/views/tour_views.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
- <!-- Make the xmlid of menus required by the HR Expense tour available in webclient -->
- <record id="menu_hr_expense_root" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-</odoo>
diff --git a/addons/hr_recruitment/__manifest__.py b/addons/hr_recruitment/__manifest__.py
index 8f7176637f7..90d3f9b043a 100644
--- a/addons/hr_recruitment/__manifest__.py
+++ b/addons/hr_recruitment/__manifest__.py
@@ -34,7 +34,6 @@ You can define the different phases of interviews and easily rate the applicant
'views/hr_recruitment_templates.xml',
'views/hr_department_views.xml',
'views/hr_job_views.xml',
- 'views/tour_views.xml',
],
'demo': [
'data/hr_recruitment_demo.xml',
diff --git a/addons/hr_recruitment/views/tour_views.xml b/addons/hr_recruitment/views/tour_views.xml
deleted file mode 100644
index 6f6a9638aa3..00000000000
--- a/addons/hr_recruitment/views/tour_views.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
- <!-- Make the xmlid of menus required by the HR Recruitment tour available in webclient -->
- <record id="menu_hr_recruitment_root" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-</odoo>
diff --git a/addons/point_of_sale/views/point_of_sale_view.xml b/addons/point_of_sale/views/point_of_sale_view.xml
index 9e86f135c23..9d12f0bce7c 100644
--- a/addons/point_of_sale/views/point_of_sale_view.xml
+++ b/addons/point_of_sale/views/point_of_sale_view.xml
@@ -4,7 +4,6 @@
<menuitem
id="menu_point_root"
name="Point of Sale"
- load_xmlid="True"
groups="group_pos_manager,group_pos_user"
web_icon="point_of_sale,static/description/icon.png"
sequence="20"/>
diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py
index 3a07959be8d..df6cbb01f0f 100644
--- a/addons/project/__manifest__.py
+++ b/addons/project/__manifest__.py
@@ -42,7 +42,6 @@ Dashboard / Reports for Project Management will include:
'views/res_partner_views.xml',
'views/res_config_views.xml',
'views/project_templates.xml',
- 'views/tour_views.xml',
'data/web_planner_data.xml',
'data/project_mail_template_data.xml',
'wizard/project_task_merge_wizard_views.xml',
diff --git a/addons/project/views/tour_views.xml b/addons/project/views/tour_views.xml
deleted file mode 100644
index 3a572ab85cc..00000000000
--- a/addons/project/views/tour_views.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
- <!-- Make the xmlid of menus required by the Project tour available in webclient -->
- <record id="menu_main_pm" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="menu_projects" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="base.menu_administration" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-</odoo>
diff --git a/addons/sale_management/__manifest__.py b/addons/sale_management/__manifest__.py
index 3d16dfbf00a..854d82f827c 100644
--- a/addons/sale_management/__manifest__.py
+++ b/addons/sale_management/__manifest__.py
@@ -43,7 +43,6 @@ The Dashboard for the Sales Manager will include
'website': 'https://www.odoo.com/page/sales',
'depends': ['sale'],
'data': [
- 'data/sale_management_tour.xml',
'views/sale_management_views.xml',
'views/sale_management_templates.xml',
],
diff --git a/addons/sale_management/data/sale_management_tour.xml b/addons/sale_management/data/sale_management_tour.xml
deleted file mode 100644
index 447ed474eab..00000000000
--- a/addons/sale_management/data/sale_management_tour.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
- <!-- Make the xmlid of menus required by the Sale tour available in webclient -->
- <record id="sales_team.menu_sales" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="sales_team.menu_base_partner" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
- <record id="base.menu_administration" model="ir.ui.menu">
- <field name="load_xmlid" eval="True"/>
- </record>
-</odoo>
diff --git a/addons/web_tour/models/__init__.py b/addons/web_tour/models/__init__.py
index 0b9e41054af..a9f4d6f4470 100644
--- a/addons/web_tour/models/__init__.py
+++ b/addons/web_tour/models/__init__.py
@@ -2,5 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
-from . import ir_ui_menu
from . import tour
diff --git a/addons/web_tour/models/ir_ui_menu.py b/addons/web_tour/models/ir_ui_menu.py
deleted file mode 100644
index 1cfb14a8d0a..00000000000
--- a/addons/web_tour/models/ir_ui_menu.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo import api, fields, models, tools
-from odoo.tools import pycompat
-
-
-class IrUiMenu(models.Model):
- _inherit = 'ir.ui.menu'
-
- load_xmlid = fields.Boolean(default=False)
-
- @api.model
- @tools.ormcache_context('self._uid', 'debug', keys=('lang',))
- def load_menus(self, debug):
- """ Extends load_menus to include requested xmlids """
- menu_root = super(IrUiMenu, self).load_menus(debug)
-
- menu_ids = [menu.id for menu in self.browse(menu_root['all_menu_ids']) if menu.load_xmlid]
- xmlids = {
- d.res_id: d.module + "." + d.name
- for d in self.env['ir.model.data'].sudo().search([('res_id', 'in', menu_ids), ('model', '=', 'ir.ui.menu')])
- }
-
- def _find_subtree(tree, node_id):
- # Returns the subtree whose id is node_id
- if tree['id'] == node_id:
- return tree
- else:
- for child in tree['children']:
- subtree = _find_subtree(child, node_id)
- if subtree:
- return subtree
-
- for menu_id, menu_xmlid in pycompat.items(xmlids):
- _find_subtree(menu_root, menu_id)['xmlid'] = menu_xmlid
-
- return menu_root
diff --git a/addons/website/views/website_navbar_templates.xml b/addons/website/views/website_navbar_templates.xml
index a3b61c2a44a..3191d20b039 100644
--- a/addons/website/views/website_navbar_templates.xml
+++ b/addons/website/views/website_navbar_templates.xml
@@ -15,7 +15,7 @@
<ul class="dropdown-menu">
<li t-as="menu" t-foreach="menu_data['children']">
<t t-set="debug_param" t-value="'?&amp;debug=' if debug else ''"/>
- <a t-att-class="'oe_menu_toggler' if menu.get('children') else 'oe_menu_leaf'" t-att-data-action-id="menu['action'] and menu['action'].split(',')[1] or None" t-att-data-action-model="menu['action'] and menu['action'].split(',')[0] or None" t-att-data-menu="menu['id']" t-att-href="'/web%s#menu_id=%s&amp;action=%s' % (debug_param, menu['id'], menu['action'] and menu['action'].split(',')[1] or '')">
+ <a t-att-class="'oe_menu_toggler' if menu.get('children') else 'oe_menu_leaf'" t-att-data-action-id="menu['action'] and menu['action'].split(',')[1] or None" t-att-data-action-model="menu['action'] and menu['action'].split(',')[0] or None" t-att-data-menu="menu['id']" t-att-data-menu-xmlid="menu.get('xmlid')" t-att-href="'/web%s#menu_id=%s&amp;action=%s' % (debug_param, menu['id'], menu['action'] and menu['action'].split(',')[1] or '')">
<i t-attf-class="fa #{menu.get('icon')} fa-lg fa-fw" t-if="menu.get('icon')"/>
<span class="oe_menu_text">
<t t-esc="menu['name']"/>
diff --git a/addons/website/views/website_views.xml b/addons/website/views/website_views.xml
index fdd6bf5a754..1b9b4c87fa5 100644
--- a/addons/website/views/website_views.xml
+++ b/addons/website/views/website_views.xml
@@ -5,7 +5,6 @@
<menuitem name="Website"
id="menu_website_configuration"
sequence="9"
- load_xmlid="True"
groups="base.group_user"
web_icon="website,static/description/icon.png"/>
diff --git a/odoo/addons/base/ir/ir_ui_menu.py b/odoo/addons/base/ir/ir_ui_menu.py
index b4bebf0e9a8..a807489f6f3 100644
--- a/odoo/addons/base/ir/ir_ui_menu.py
+++ b/odoo/addons/base/ir/ir_ui_menu.py
@@ -206,7 +206,8 @@ class IrUiMenu(models.Model):
fields = ['name', 'sequence', 'parent_id', 'action', 'web_icon_data']
menu_roots = self.get_user_roots()
menu_roots_data = menu_roots.read(fields) if menu_roots else []
- return {
+
+ menu_root = {
'id': False,
'name': 'root',
'parent_id': [-1, ''],
@@ -214,6 +215,10 @@ class IrUiMenu(models.Model):
'all_menu_ids': menu_roots.ids,
}
+ menu_roots._set_menuitems_xmlids(menu_root)
+
+ return menu_root
+
@api.model
@tools.ormcache_context('self._uid', 'debug', keys=('lang',))
def load_menus(self, debug):
@@ -232,6 +237,7 @@ class IrUiMenu(models.Model):
'children': menu_roots_data,
'all_menu_ids': menu_roots.ids,
}
+
if not menu_roots_data:
return menu_root
@@ -258,4 +264,25 @@ class IrUiMenu(models.Model):
for menu_item in menu_items:
menu_item.setdefault('children', []).sort(key=operator.itemgetter('sequence'))
+ (menu_roots + menus)._set_menuitems_xmlids(menu_root)
+
return menu_root
+
+ def _set_menuitems_xmlids(self, menu_root):
+ menuitems = self.env['ir.model.data'].sudo().search([
+ ('res_id', 'in', self.ids),
+ ('model', '=', 'ir.ui.menu')
+ ])
+
+ xmlids = {
+ menu.res_id: menu.complete_name
+ for menu in menuitems
+ }
+
+ def _set_xmlids(tree, xmlids):
+ tree['xmlid'] = xmlids.get(tree['id'], '')
+ if 'children' in tree:
+ for child in tree['children']:
+ _set_xmlids(child, xmlids)
+
+ _set_xmlids(menu_root, xmlids)
diff --git a/odoo/import_xml.rng b/odoo/import_xml.rng
index 81fef2b35c6..36546c39946 100644
--- a/odoo/import_xml.rng
+++ b/odoo/import_xml.rng
@@ -239,9 +239,6 @@
<rng:optional> <rng:attribute name="action"/> </rng:optional>
<rng:optional> <rng:attribute name="sequence"/> </rng:optional>
<rng:optional> <rng:attribute name="groups"/> </rng:optional>
- <rng:optional>
- <rng:attribute name="load_xmlid"><rng:value>True</rng:value></rng:attribute>
- </rng:optional>
<!-- TODO: remove icon stuff -->
<rng:optional> <rng:attribute name="icon"/> </rng:optional>
<rng:optional> <rng:attribute name="web_icon"/> </rng:optional>
diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py
index 61fc15c7a54..6997a2e1b30 100644
--- a/odoo/tools/convert.py
+++ b/odoo/tools/convert.py
@@ -513,8 +513,6 @@ form: module.record_id""" % (xml_id,)
# ensure menu has a name
values['name'] = rec_id or '?'
- if rec.get('load_xmlid'):
- values['load_xmlid'] = True
if rec.get('sequence'):
values['sequence'] = int(rec.get('sequence'))