Skip to content

Commit

Permalink
[FIX] restrict_mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
tarteo authored Sep 23, 2024
1 parent 3cc77b9 commit d2d9d67
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions container_accessibility/models/restrict_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ 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()
if restrict_domain is None or not self.filtered_domain(restrict_domain):
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()


Expand Down

0 comments on commit d2d9d67

Please sign in to comment.