summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2018-10-01 17:28:56 +0200
committerYannick Tivisse <yti@odoo.com>2018-10-02 12:35:34 +0200
commitb2b9545cf38855fdb97e992aa2883cdab6909e96 (patch)
tree0af0977a19c1dbf03c65426183e5bed36180f403
parenteaba05b9ae631cb907406996b3e4a79232965c22 (diff)
[IMP] ir_ui_view: Log warning on incorrect 'groups' attribute
Purpose ======= They are a lot of places where we set an attribute 'groups' on a view element and: - The group doesn't exist anymore - The group xmlid is not correct - The group xmlid exists but the modularity is not respected (example: group_stock_user used in a view in the 'product' module). Where it happens, nothing warns the user or the developer. The element is just never rendered. Specification ============= In the method _check_xml, log a warning if a 'groups' attribute is set and if a group doesn't not exist at that moment.
-rw-r--r--odoo/addons/base/models/ir_ui_view.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py
index 04464f981c0..96e0593cbc1 100644
--- a/odoo/addons/base/models/ir_ui_view.py
+++ b/odoo/addons/base/models/ir_ui_view.py
@@ -320,6 +320,12 @@ actual arch.
self.raise_view_error(message, self.id)
return True
+ def _check_groups_validity(self, view, view_name):
+ for node in view.xpath('//*[@groups]'):
+ for group in node.get('groups').replace('!', '').split(','):
+ if not self.env.ref(group.strip(), raise_if_not_found=False):
+ _logger.warning("The group %s defined in view %s does not exist!", group, view_name)
+
@api.constrains('arch_db')
def _check_xml(self):
# Sanity checks: the view should not break anything upon rendering!
@@ -332,6 +338,7 @@ actual arch.
view_arch_utf8 = view_def['arch']
if view.type != 'qweb':
view_doc = etree.fromstring(view_arch_utf8)
+ self._check_groups_validity(view_doc, view.name)
# verify that all fields used are valid, etc.
self.postprocess_and_fields(view.model, view_doc, view.id)
# RNG-based validation is not possible anymore with 7.0 forms