Skip to content

Commit

Permalink
edi_oca: Fix Access error for Administrator
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed May 8, 2024
1 parent fac3327 commit 3d11fcf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions edi_oca/models/edi_exchange_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ def _search(
count=False,
access_rights_uid=access_rights_uid,
)
if self.env.is_system():
# restrictions do not apply to group "Settings"
if self.env.is_superuser():
# restrictions do not apply for the superuser
return len(ids) if count else ids

# TODO highlight orphaned EDI records in UI:
Expand Down Expand Up @@ -519,6 +519,9 @@ def _search(
.with_context(active_test=False)
._search([("id", "in", recs.ids)])
)
if self.env.is_system():
# Group "Settings" can list exchanges where record is deleted
allowed.extend(missing.ids)
for target_id in allowed:
result += list(targets[target_id])
if len(orig_ids) == limit and len(result) < len(orig_ids):
Expand All @@ -545,7 +548,7 @@ def read(self, fields=None, load="_classic_read"):
def check_access_rule(self, operation):
"""In order to check if we can access a record, we are checking if we can access
the related document"""
super(EDIExchangeRecord, self).check_access_rule(operation)
super().check_access_rule(operation)
if self.env.is_superuser():
return
default_checker = self.env["edi.exchange.consumer.mixin"].get_edi_access
Expand Down
2 changes: 1 addition & 1 deletion edi_oca/tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_search_no_record_admin(self):
exchange_record = self.create_record()
exchange_record.res_id = -1
admin_group = self.env.ref("base.group_system")
self.user.write({"groups_id": [(4, admin_group.id)]})
self.user.write({"groups_id": [(4, self.group.id), (4, admin_group.id)]})
self.assertEqual(
1,
self.env["edi.exchange.record"]
Expand Down

0 comments on commit 3d11fcf

Please sign in to comment.