|
@ -1,5 +1,6 @@ |
|
|
# Copyright 2022 Tecnativa - Víctor Martínez |
|
|
# Copyright 2022 Tecnativa - Víctor Martínez |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
|
|
|
from lxml import etree |
|
|
|
|
|
|
|
|
from odoo.tests import common, new_test_user |
|
|
from odoo.tests import common, new_test_user |
|
|
|
|
|
|
|
@ -22,6 +23,7 @@ class TestPartnerCategorySecurity(common.SavepointCase): |
|
|
login="Test partner category manager", |
|
|
login="Test partner category manager", |
|
|
groups="partner_category_security.group_partner_category_manager", |
|
|
groups="partner_category_security.group_partner_category_manager", |
|
|
) |
|
|
) |
|
|
|
|
|
cls.partner_model = cls.env["res.partner"] |
|
|
cls.partner_category_model = cls.env["res.partner.category"] |
|
|
cls.partner_category_model = cls.env["res.partner.category"] |
|
|
|
|
|
|
|
|
def test_check_access_rights_basic_user(self): |
|
|
def test_check_access_rights_basic_user(self): |
|
@ -34,7 +36,7 @@ class TestPartnerCategorySecurity(common.SavepointCase): |
|
|
def test_check_access_rights_partner_category_user(self): |
|
|
def test_check_access_rights_partner_category_user(self): |
|
|
model = self.partner_category_model.with_user(self.partner_category_user) |
|
|
model = self.partner_category_model.with_user(self.partner_category_user) |
|
|
self.assertTrue(model.check_access_rights("read", False)) |
|
|
self.assertTrue(model.check_access_rights("read", False)) |
|
|
self.assertTrue(model.check_access_rights("write", False)) |
|
|
|
|
|
|
|
|
self.assertFalse(model.check_access_rights("write", False)) |
|
|
self.assertFalse(model.check_access_rights("create", False)) |
|
|
self.assertFalse(model.check_access_rights("create", False)) |
|
|
self.assertFalse(model.check_access_rights("unlink", False)) |
|
|
self.assertFalse(model.check_access_rights("unlink", False)) |
|
|
|
|
|
|
|
@ -44,3 +46,20 @@ class TestPartnerCategorySecurity(common.SavepointCase): |
|
|
self.assertTrue(model.check_access_rights("write", False)) |
|
|
self.assertTrue(model.check_access_rights("write", False)) |
|
|
self.assertTrue(model.check_access_rights("create", False)) |
|
|
self.assertTrue(model.check_access_rights("create", False)) |
|
|
self.assertTrue(model.check_access_rights("unlink", False)) |
|
|
self.assertTrue(model.check_access_rights("unlink", False)) |
|
|
|
|
|
|
|
|
|
|
|
def test_partner_model_fields_view_get(self): |
|
|
|
|
|
res = self.partner_model.with_user(self.basic_user).fields_view_get( |
|
|
|
|
|
view_type="form" |
|
|
|
|
|
) |
|
|
|
|
|
node = etree.XML(res["arch"]).xpath("//field[@name='category_id']")[0] |
|
|
|
|
|
self.assertTrue(res["fields"]["category_id"]["readonly"]) |
|
|
|
|
|
self.assertEqual(node.get("readonly"), "1") |
|
|
|
|
|
self.assertEqual(node.get("force_save"), "1") |
|
|
|
|
|
res = self.partner_model.with_user(self.partner_category_user).fields_view_get( |
|
|
|
|
|
view_type="form" |
|
|
|
|
|
) |
|
|
|
|
|
self.assertFalse(res["fields"]["category_id"]["readonly"]) |
|
|
|
|
|
res = self.partner_model.with_user( |
|
|
|
|
|
self.partner_category_manager |
|
|
|
|
|
).fields_view_get(view_type="form") |
|
|
|
|
|
self.assertFalse(res["fields"]["category_id"]["readonly"]) |