Skip to content
Permalink
Browse files

ir_ui_view: code imp

  • Loading branch information...
rco-odoo committed Nov 7, 2019
1 parent 4d5a8bb commit 6e63a10b947a4c19715269ecf7432ee2f2d1a02f
Showing with 10 additions and 6 deletions.
  1. +10 −6 odoo/addons/base/models/ir_ui_view.py
@@ -581,7 +581,10 @@ def get_inheriting_views_arch(self, model):
valid_view_ids = [r[0] for r in self.env.cr.fetchall()] + check_view_ids
view_ids = [vid for vid in view_ids if vid in valid_view_ids]

return self.browse(view_ids).sudo().filtered(lambda view: not view.groups_id or (view.groups_id & self.env.user.groups_id))
def accessible(view):
return not view.groups_id or (view.groups_id & self.env.user.groups_id)

return self.browse(view_ids).sudo().filtered(accessible)

def handle_view_error(self, message, raise_exception=True):
""" Handle a view error by raising an exception or logging a warning,
@@ -654,9 +657,11 @@ def apply_inheritance_specs(self, source, specs_tree, pre_locate=lambda s: True)
# Queue of specification nodes (i.e. nodes describing where and
# changes to apply to some parent architecture).
try:
source = apply_inheritance_specs(source, specs_tree,
inherit_branding=self._context.get('inherit_branding'),
pre_locate=pre_locate)
source = apply_inheritance_specs(
source, specs_tree,
inherit_branding=self._context.get('inherit_branding'),
pre_locate=pre_locate,
)
except ValueError as e:
self.handle_view_error(str(e))
return source
@@ -670,9 +675,8 @@ def apply_view_inheritance(self, source, model):
views with that specific model will be applied.
:return: a modified source where all the modifying architecture are applied
"""
sql_inherit = self.get_inheriting_views_arch(model)
inherit_tree = collections.defaultdict(list)
for view in sql_inherit:
for view in self.get_inheriting_views_arch(model):
inherit_tree[view.inherit_id].append(view)
return self._apply_view_inheritance(source, inherit_tree)

0 comments on commit 6e63a10

Please sign in to comment.
You can’t perform that action at this time.