From 3127164937f0610e2302806de4a8046f2f1dd441 Mon Sep 17 00:00:00 2001 From: KevinKhao Date: Tue, 26 Jan 2021 00:33:40 +0100 Subject: [PATCH] [IMP] base_user_role: UX improvements --- base_user_role/models/role.py | 7 +++++++ base_user_role/readme/CONTRIBUTORS.rst | 1 + base_user_role/views/user.xml | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/base_user_role/models/role.py b/base_user_role/models/role.py index 7164e8c0c..7718013b8 100644 --- a/base_user_role/models/role.py +++ b/base_user_role/models/role.py @@ -92,6 +92,13 @@ class ResUsersRoleLine(models.Model): company_id = fields.Many2one( "res.company", "Company", default=lambda self: self.env.user.company_id ) + _sql_constraints = [ + ( + "user_role_uniq", + "unique (user_id,role_id)", + "Roles can be assigned to a user only once at a time", + ) + ] @api.constrains("user_id", "company_id") def _check_company(self): diff --git a/base_user_role/readme/CONTRIBUTORS.rst b/base_user_role/readme/CONTRIBUTORS.rst index b0539e398..b34cf97aa 100644 --- a/base_user_role/readme/CONTRIBUTORS.rst +++ b/base_user_role/readme/CONTRIBUTORS.rst @@ -3,5 +3,6 @@ * Jean-Charles Drubay (https://komit-consulting.com) * Alan Ramos (https://www.jarsa.com.mx) * Harald Panten +* Kevin Khao Do not contact contributors directly about support or help with technical issues. diff --git a/base_user_role/views/user.xml b/base_user_role/views/user.xml index 2adcafae0..0430a48f0 100644 --- a/base_user_role/views/user.xml +++ b/base_user_role/views/user.xml @@ -10,9 +10,13 @@ + - +