Skip to content

Commit

Permalink
[MIG] partner_readonly_security: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianSantamaria committed Jan 13, 2025
1 parent 8b54b19 commit 1c70ce5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion partner_readonly_security/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Partner Readonly Security",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"version": "15.0.1.0.0",
"version": "17.0.1.0.0",
"depends": ["base"],
"license": "AGPL-3",
"category": "Customer Relationship Management",
Expand Down
30 changes: 28 additions & 2 deletions partner_readonly_security/tests/test_partner_readonly_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ def setUpClass(cls):
cls.user_admin = new_test_user(
cls.env,
login="test_user_admin",
groups="base.group_user,base.group_partner_manager,%s"
% ("partner_readonly_security.group_partner_edition",),
groups="""
base.group_user,base.group_partner_manager,
partner_readonly_security.group_partner_edition
""",
)
cls.user_readonly = new_test_user(
cls.env,
Expand Down Expand Up @@ -58,3 +60,27 @@ def test_partner_readonly(self):
self.partner.with_user(self.env.user).unlink()
with self.assertRaises(AccessError):
self.env["res.partner"].create({"name": "Test partner 2"})

@users("test_user_readonly")
def test_partner_readonly_no_raise(self):
"""Read allowed. Write, unlink and create return False
without exception when raise_exception=False."""
partners = self.env["res.partner"].search([])
self.assertIn(self.partner, partners)

result = self.partner.with_user(self.env.user).check_access_rights(
"write", raise_exception=False
)
self.assertFalse(result)

result = self.partner.with_user(self.env.user).check_access_rights(
"unlink", raise_exception=False
)
self.assertFalse(result)

result = (
self.env["res.partner"]
.with_user(self.env.user)
.check_access_rights("create", raise_exception=False)
)
self.assertFalse(result)

0 comments on commit 1c70ce5

Please sign in to comment.