diff --git a/muk_utils/__manifest__.py b/muk_utils/__manifest__.py index 675fc8b..04183ac 100644 --- a/muk_utils/__manifest__.py +++ b/muk_utils/__manifest__.py @@ -19,7 +19,7 @@ { "name": "MuK Utils", "summary": """Utility Features""", - "version": '12.0.1.4.3', + "version": '12.0.1.4.4', "category": 'Extra Tools', "license": "AGPL-3", "author": "MuK IT", diff --git a/muk_utils/models/base.py b/muk_utils/models/base.py index b7f5ab1..ffadc18 100644 --- a/muk_utils/models/base.py +++ b/muk_utils/models/base.py @@ -44,6 +44,31 @@ class Base(models.AbstractModel): parent_domain = [[self._parent_name, '=', parent_id]] return expression.AND(parent_domain, domain) if domain else parent_domain + #---------------------------------------------------------- + # Security + #---------------------------------------------------------- + + @api.multi + def _filter_access(self, operation): + if self.check_access_rights(operation, False): + return self._filter_access_rules(operation) + return self.env[self._name] + + @api.multi + def _filter_access_ids(self, operation): + return self._filter_access(operation).ids + + @api.multi + def check_access(self, operation, raise_exception=False): + try: + access_right = self.check_access_rights(operation, raise_exception) + access_rule = self.check_access_rule(operation) is None + return access_right and access_rule + except AccessError: + if raise_exception: + raise + return False + #---------------------------------------------------------- # Hierarchy Methods #---------------------------------------------------------- diff --git a/muk_utils/models/mixins_hierarchy.py b/muk_utils/models/mixins_hierarchy.py index 2af3bf2..f40b07c 100644 --- a/muk_utils/models/mixins_hierarchy.py +++ b/muk_utils/models/mixins_hierarchy.py @@ -71,7 +71,7 @@ class Hierarchy(models.AbstractModel): def _compute_parent_path(self): paths = [list(map(int, rec.parent_path.split('/')[:-1])) for rec in self] ids = set(functools.reduce(operator.concat, paths)) - data = dict(self.browse(ids).name_get()) + data = dict(self.browse(ids)._filter_access('read').name_get()) for record in self: path_names = [""] path_json = []