Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base_user_role/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def _compute_show_alert(self):
for user in self:
user.show_alert = user.role_line_ids.filtered(lambda rec: rec.is_enabled)

role_ids = fields.One2many(
user_role_ids = fields.One2many(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a migration script needed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because the field is a computed non-store field

comodel_name="res.users.role",
string="User Roles",
string="Roles",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to change this. Do you have a good reason for this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this change to fix this warning WARNING odoo odoo.addons.base.models.ir_model: Two fields (user_role_ids, role_ids) of res.users() have the same label: User Roles. [Modules: base_user_role and mail]

compute="_compute_role_ids",
compute_sudo=True,
groups="base.group_erp_manager",
Expand All @@ -44,7 +44,7 @@ def _default_role_lines(self):
@api.depends("role_line_ids.role_id")
def _compute_role_ids(self):
for user in self:
user.role_ids = user.role_line_ids.mapped("role_id")
user.user_role_ids = user.role_line_ids.mapped("role_id")

@api.model_create_multi
def create(self, vals_list):
Expand Down
2 changes: 1 addition & 1 deletion base_user_role/tests/test_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_default_user_roles(self):
{"name": "USER TEST (DEFAULT ROLES)", "login": "user_test_default_roles"}
)
roles = self.role_model.browse([self.role1_id.id, self.role2_id.id])
self.assertEqual(user.role_ids, roles)
self.assertEqual(user.user_role_ids, roles)

def test_role_multicompany(self):
"""Test AccessError when admin-like user accesses a role"""
Expand Down
8 changes: 4 additions & 4 deletions base_user_role/views/user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<field name="arch" type="xml">
<xpath expr="//notebook/page[1]" position="before">
<page string="User Roles">
<field name="role_ids" invisible="1" />
<field name="user_role_ids" invisible="1" />
<field name="role_line_ids" nolabel="1">
<list editable="bottom" decoration-muted="not is_enabled">
<field
name="role_id"
domain="[('id', 'not in', parent.role_ids)]"
domain="[('id', 'not in', parent.user_role_ids)]"
/>
<field name="date_from" />
<field name="date_to" />
Expand Down Expand Up @@ -52,7 +52,7 @@
<field name="arch" type="xml">
<field name="company_ids" position="after">
<field
name="role_ids"
name="user_role_ids"
filter_domain="[('role_line_ids.role_id.name','ilike',self)]"
/>
</field>
Expand All @@ -63,7 +63,7 @@
<field name="inherit_id" ref="base.view_users_tree" />
<field name="arch" type="xml">
<field name="role" position="after">
<field name="role_ids" widget="many2many_tags" />
<field name="user_role_ids" widget="many2many_tags" />
</field>
</field>
</record>
Expand Down