[FIX] base: invisible groups default on user creation
Since 16.0's 0501bbd62e fields with groups are now removed from the view
instead of being set as invisible.
Scenario:
- template user has group "Access to export feature"
- create a new user while being in debug=0 mode
- save
=> the users don't have the group "Access to export feature" set,
because the corresponding field is not in the view. If the same scenario
was done in debug=1 mode, we would get the group set.
Solution: duplicate the field that are inside base.group_no_one section
and have them be invisible if someone is not in debug mode.
note: before the fix, added assert fails because there is missing groups
in the newly created user.
closes odoo/odoo#121097
Note: issue observed when working on another ticket
X-original-commit: 9deb1e6aa902a09c4fd6a91ecbd34a89b9c98f98
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -1440,6 +1440,8 @@ class GroupsView(models.Model):
|
||||
dest_group.append(E.field(name=field_name, invisible="1", **attrs))
|
||||
else:
|
||||
dest_group.append(E.field(name=field_name, **attrs))
|
||||
# add duplicate invisible field so default values are saved on create
|
||||
xml0.append(E.field(name=field_name, **dict(attrs, invisible="1", groups='!base.group_no_one')))
|
||||
group_count += 1
|
||||
xml4.append(E.group(*left_group))
|
||||
xml4.append(E.group(*right_group))
|
||||
|
||||
@@ -238,6 +238,10 @@ class TestUsers2(TransactionCase):
|
||||
|
||||
self.assertIn(self.env.ref('base.group_user'), user.groups_id)
|
||||
|
||||
# all template user groups are copied
|
||||
default_user = self.env.ref('base.default_user')
|
||||
self.assertEqual(default_user.groups_id, user.groups_id)
|
||||
|
||||
def test_selection_groups(self):
|
||||
# create 3 groups that should be in a selection
|
||||
app = self.env['ir.module.category'].create({'name': 'Foo'})
|
||||
|
||||
Reference in New Issue
Block a user