mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
IMPL calls super in group_backend res_users compute_share
FIX applies pre-commit IMPL adds test for share of backend user FIX pre-commit pass IMPL removes mail.activity.mixin from dummy model because it is not needed for the test IMPL renames and divide the base_group_backend into 2 groups one that provide the basic rights and another that allow login in the app IMPL changes backend ui users to a user type FIX pre-commit pass FIX removes useless imports FIX adds share to group_backend_ui_users IMPL adds mail_channel to access rights FIX tests now working FIX pre-commit pass
This commit is contained in:
committed by
David Beal
parent
48a8d4eec1
commit
93eafb5001
@@ -8,7 +8,6 @@ _logger = logging.getLogger(__name__)
|
||||
class Users(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
# TODO: (franz) make it clear why we test with "." group and why the share = True
|
||||
@api.model
|
||||
def has_group(self, group_ext_id):
|
||||
"""While ensuring a user is part of `base.group_user` this code will
|
||||
@@ -25,21 +24,27 @@ class Users(models.Model):
|
||||
res = super().has_group(group_ext_id)
|
||||
if not res and (group_ext_id == "base.group_user"):
|
||||
has_base_group_backend = super().has_group(
|
||||
"base_group_backend.group_backend"
|
||||
)
|
||||
"base_group_backend.base_group_backend"
|
||||
) or super().has_group("base_group_backend.group_backend_ui_users")
|
||||
if has_base_group_backend:
|
||||
_logger.warning("Forcing has_group to return True for group_backend")
|
||||
_logger.warning(
|
||||
"Forcing has_group to return True"
|
||||
+ " for group_backend and base_group_backend_ui_users"
|
||||
)
|
||||
return has_base_group_backend
|
||||
return res
|
||||
|
||||
@api.depends("groups_id")
|
||||
def _compute_share(self):
|
||||
user_group_id = self.env["ir.model.data"]._xmlid_to_res_id("base.group_user")
|
||||
res = super()._compute_share()
|
||||
backend_user_group_id = self.env["ir.model.data"]._xmlid_to_res_id(
|
||||
"base_group_backend.group_backend"
|
||||
"base_group_backend.base_group_backend"
|
||||
)
|
||||
backend_ui_user_group_id = self.env["ir.model.data"]._xmlid_to_res_id(
|
||||
"base_group_backend.group_backend_ui_users"
|
||||
)
|
||||
internal_users = self.filtered_domain(
|
||||
[("groups_id", "in", [user_group_id, backend_user_group_id])]
|
||||
[("groups_id", "in", [backend_user_group_id, backend_ui_user_group_id])]
|
||||
)
|
||||
internal_users.share = False
|
||||
(self - internal_users).share = True
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user