From d2d9d67f3d84ac9829c253340cfe6afe55277dee Mon Sep 17 00:00:00 2001 From: Dennis Sluijk <10028499+tarteo@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:00:35 +0200 Subject: [PATCH] [FIX] restrict_mixin --- container_accessibility/models/restrict_mixin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/container_accessibility/models/restrict_mixin.py b/container_accessibility/models/restrict_mixin.py index 13a89a7..fd763eb 100644 --- a/container_accessibility/models/restrict_mixin.py +++ b/container_accessibility/models/restrict_mixin.py @@ -17,11 +17,11 @@ def _get_restrict_domain(self): """ return None - def _check_restrict(self, action): + def _check_restrict(self): if ( not self.env.user.is_restricted_user() or self.env.su - or (not self and action != "create") # Deleting / writing empty recordsets + or not self # Deleting / writing empty recordsets, creating with empty vals_list ): return restrict_domain = self._get_restrict_domain() @@ -29,16 +29,17 @@ def _check_restrict(self, action): raise AccessError(_("Access denied to this model (%s)", self._name)) def write(self, vals): - self._check_restrict("write") + self._check_restrict() return super().write(vals) @api.model_create_multi def create(self, vals_list): - self._check_restrict("create") - return super().create(vals_list) + res = super().create(vals_list) + res._check_restrict() + return res def unlink(self): - self._check_restrict("unlink") + self._check_restrict() return super().unlink()