Browse Source

publish muk_utils - 12.0

pull/9/head
MuK IT GmbH 6 years ago
parent
commit
a623b058a8
  1. 2
      muk_utils/__manifest__.py
  2. 25
      muk_utils/models/base.py
  3. 2
      muk_utils/models/mixins_hierarchy.py

2
muk_utils/__manifest__.py

@ -19,7 +19,7 @@
{ {
"name": "MuK Utils", "name": "MuK Utils",
"summary": """Utility Features""", "summary": """Utility Features""",
"version": '12.0.1.4.3',
"version": '12.0.1.4.4',
"category": 'Extra Tools', "category": 'Extra Tools',
"license": "AGPL-3", "license": "AGPL-3",
"author": "MuK IT", "author": "MuK IT",

25
muk_utils/models/base.py

@ -44,6 +44,31 @@ class Base(models.AbstractModel):
parent_domain = [[self._parent_name, '=', parent_id]] parent_domain = [[self._parent_name, '=', parent_id]]
return expression.AND(parent_domain, domain) if domain else parent_domain 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 # Hierarchy Methods
#---------------------------------------------------------- #----------------------------------------------------------

2
muk_utils/models/mixins_hierarchy.py

@ -71,7 +71,7 @@ class Hierarchy(models.AbstractModel):
def _compute_parent_path(self): def _compute_parent_path(self):
paths = [list(map(int, rec.parent_path.split('/')[:-1])) for rec in self] paths = [list(map(int, rec.parent_path.split('/')[:-1])) for rec in self]
ids = set(functools.reduce(operator.concat, paths)) 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: for record in self:
path_names = [""] path_names = [""]
path_json = [] path_json = []

Loading…
Cancel
Save