diff options
| author | Raphael Collet <rco@odoo.com> | 2020-04-07 08:09:45 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-04-07 09:25:00 +0000 |
| commit | 1dc3c0d1a810a5b35e98d11ae6de1fc5042146c3 (patch) | |
| tree | 94cd54e910b5ec1b2e0436117f43f44e8c331f30 /odoo | |
| parent | 00404541e05efddf491e6f41718595f2313d7b98 (diff) | |
[FIX] base: use a dummy "user groups view" during install
While installing a module on an existing database, the modification of
groups should reset the `base.user_groups_view` to a dummy view in order
to validate user views. The `user_groups_view` is set to its "right"
value at the end of the installation.
closes odoo/odoo#49114
X-original-commit: 071bd77944484bad6f2c0cb9a7a98785dcc693c6
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/addons/base/models/res_users.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index 5de93594416..6c41d3a0789 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -1090,17 +1090,20 @@ class GroupsView(models.Model): """ Modify the view with xmlid ``base.user_groups_view``, which inherits the user form view, and introduces the reified group fields. """ - if self._context.get('install_filename') or self._context.get(MODULE_UNINSTALL_FLAG): - # skip now; it will be updated once at the end of (un)installation - return - # remove the language to avoid translations, it will be handled at the view level self = self.with_context(lang=None) # We have to try-catch this, because at first init the view does not # exist but we are already creating some basic groups. view = self.env.ref('base.user_groups_view', raise_if_not_found=False) - if view and view.exists() and view._name == 'ir.ui.view': + if not (view and view.exists() and view._name == 'ir.ui.view'): + return + + if self._context.get('install_filename') or self._context.get(MODULE_UNINSTALL_FLAG): + # use a dummy view during install/upgrade/uninstall + xml = E.field(name="groups_id", position="after") + + else: group_no_one = view.env.ref('base.group_no_one') group_employee = view.env.ref('base.group_user') xml1, xml2, xml3 = [], [], [] @@ -1168,13 +1171,14 @@ class GroupsView(models.Model): E.group(*(xml2), col="2", attrs=str(user_type_attrs)), E.group(*(xml3), col="4", attrs=str(user_type_attrs)), name="groups_id", position="replace") xml.addprevious(etree.Comment("GENERATED AUTOMATICALLY BY GROUPS")) - xml_content = etree.tostring(xml, pretty_print=True, encoding="unicode") - if xml_content != view.arch: # avoid useless xml validation if no change - new_context = dict(view._context) - new_context.pop('install_filename', None) # don't set arch_fs for this computed view - new_context['lang'] = None - view.with_context(new_context).write({'arch': xml_content}) + # serialize and update the view + xml_content = etree.tostring(xml, pretty_print=True, encoding="unicode") + if xml_content != view.arch: # avoid useless xml validation if no change + new_context = dict(view._context) + new_context.pop('install_filename', None) # don't set arch_fs for this computed view + new_context['lang'] = None + view.with_context(new_context).write({'arch': xml_content}) def get_application_groups(self, domain): """ Return the non-share groups that satisfy ``domain``. """ |
