diff --git a/web_access_rule_buttons/models/models.py b/web_access_rule_buttons/models/models.py index 629778e7..f093feb8 100644 --- a/web_access_rule_buttons/models/models.py +++ b/web_access_rule_buttons/models/models.py @@ -18,7 +18,7 @@ class Base(models.AbstractModel): :param operation: a list of ``read``, ``create``, ``write``, ``unlink`` :return: {operation: access} (access is a boolean) """ - if operations or None: + if not operations: operations = ['read', 'create', 'write', 'unlink'] result = {} for operation in operations: diff --git a/web_access_rule_buttons/tests/__init__.py b/web_access_rule_buttons/tests/__init__.py new file mode 100644 index 00000000..1c1376d5 --- /dev/null +++ b/web_access_rule_buttons/tests/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import test_access_rule_buttons diff --git a/web_access_rule_buttons/tests/test_access_rule_buttons.py b/web_access_rule_buttons/tests/test_access_rule_buttons.py new file mode 100644 index 00000000..47774b4d --- /dev/null +++ b/web_access_rule_buttons/tests/test_access_rule_buttons.py @@ -0,0 +1,19 @@ +# Copyright 2019 Onestein BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests.common import TransactionCase + + +class TestAccessRuleButtons(TransactionCase): + def setUp(self): + super(TestAccessRuleButtons, self).setUp() + + self.curr_obj = self.env['res.currency'] + self.curr_record = self.env.ref('base.USD') + + def test_check_access_rule_1(self): + res = self.curr_obj.check_access_rule_all(['write']) + self.assertTrue(res['write']) + + def test_check_access_rule_2(self): + res = self.curr_record.check_access_rule_all(['write']) + self.assertTrue(res['write'])