From 3c628bae4984c24f91a54e2b208e5dccb65218f9 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 11 Jun 2018 11:11:53 +0200 Subject: [PATCH] [FIX] base: allow erp manager to set multi-company on a user If a user member of group 'group_erp_manager' create a new user and adds the user in multiple companies, the system raises an AccessError on ir.ui.view When adding a user in multiple companies, he is automatically added in the 'base.group_multi_company' group. Modifying a 'res.group' record recomputes the view architecture. The ir.ui.view records is writable by 'base.group_system' users. Closes #21207 --- odoo/addons/base/res/res_users.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odoo/addons/base/res/res_users.py b/odoo/addons/base/res/res_users.py index c621ca477f5..a78ecb9829c 100644 --- a/odoo/addons/base/res/res_users.py +++ b/odoo/addons/base/res/res_users.py @@ -775,6 +775,11 @@ class GroupsView(models.Model): xml = E.field(E.group(*(xml1), col="2"), E.group(*(xml2), col="4"), name="groups_id", position="replace") xml.addprevious(etree.Comment("GENERATED AUTOMATICALLY BY GROUPS")) xml_content = etree.tostring(xml, pretty_print=True, xml_declaration=True, encoding="utf-8") + if not view.check_access_rights('write', raise_exception=False): + # erp manager has the rights to update groups/users but not + # to modify ir.ui.view + if self.env.user.has_group('base.group_erp_manager'): + view = view.sudo() view.with_context(lang=None).write({'arch': xml_content, 'arch_fs': False}) def get_application_groups(self, domain):