Skip to content

Commit

Permalink
Merge PR #986 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Jun 19, 2024
2 parents 9144e59 + 2b3784d commit 186ec35
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 101 deletions.
19 changes: 0 additions & 19 deletions edi_oca/migrations/14.0.1.10.0/post-migrate.py

This file was deleted.

35 changes: 0 additions & 35 deletions edi_oca/migrations/14.0.1.20.0/post-migrate.py

This file was deleted.

42 changes: 0 additions & 42 deletions edi_oca/migrations/14.0.1.20.0/pre-migrate.py

This file was deleted.

11 changes: 7 additions & 4 deletions edi_oca/models/edi_exchange_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ def _search(
count=False,
access_rights_uid=access_rights_uid,
)
if self.env.user._is_system():
# rules do not apply to group "Settings"
if self.env.user._is_superuser():
# rules do not apply for the superuser
return len(ids) if count else ids

# TODO highlight orphaned EDI records in UI:
Expand Down Expand Up @@ -520,11 +520,14 @@ def _search(
list(targets[res_id]),
)
recs = recs - missing
allowed = (
allowed = list(
self.env[model]
.with_context(active_test=False)
._search([("id", "in", recs.ids)])
)
if self.env.user._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 @@ -551,7 +554,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.user._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 @@ -198,7 +198,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 186ec35

Please sign in to comment.