From 6ad3d40172db56b8db092481e6efe7687190decf Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 21 Oct 2022 13:00:42 +0000 Subject: [PATCH] [FIX] base: ensure the removal of `` See the explanation here: https://github.com/odoo/odoo/blob/5069c8fd1cee063827873de0f6c2d9fe938337a9/odoo/addons/base/models/ir_ui_view.py#L1209-L1217 The strategy was to create a temporary node which gets deleted after the postprocessing. The deletion counted on the fact `groups` was the only attribute set to delete this temporary technical node. In case someone configured manually in a view architecture directly a t node with a groups and something else. But, studio adds another attribute to nodes with "groups=" in the context of the studio edition (`studio=True` in the context) https://github.com/odoo/enterprise/blob/7e66f89e1c85852908edc45e72706e51838960b0/web_studio/models/ir_ui_view.py#L53 and therefore another attribute was added on this temporary technical node, which therefore didn't get deleted properly before being send to the webclient. So, we change the heuristic, instead of relying no the fact `groups` was the only attribute, set a technical attribute on the node to identify it comes directly from the postprocessing and it must be deleted properly before being sent to the webclient. closes odoo/odoo#103832 X-original-commit: 53c684a69bbe8894f05306631272bcf08c226f96 Related: odoo/enterprise#33096 Signed-off-by: Denis Ledoux (dle) --- odoo/addons/base/models/ir_ui_view.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py index 6904e950e23..f55f44591e8 100644 --- a/odoo/addons/base/models/ir_ui_view.py +++ b/odoo/addons/base/models/ir_ui_view.py @@ -1036,8 +1036,8 @@ actual arch. for node in tree.xpath('//*[@groups]'): if not self.user_has_groups(node.attrib.pop('groups')): node.getparent().remove(node) - elif node.tag == 't' and not node.attrib: - # Move content of blocks with no other instructions than just "groups=" to the parent + elif node.get('postprocess_remove'): + # Move content of blocks created in `_postprocess_tag_field` to the parent # and remove the node. # This is to keep the structure # @@ -1045,6 +1045,14 @@ actual arch. # # # so the web client adds the label as expected. + # This is also to avoid having nodes in tree views + # e.g. + # + # + # + # + # + # for child in reversed(node): node.addnext(child) node.getparent().remove(node) @@ -1215,7 +1223,7 @@ actual arch. # set on the field in the Python model # e.g. # The node will be removed later, in _postprocess_access_rights. - node_t = E.t(groups=field.groups) + node_t = E.t(groups=field.groups, postprocess_remove="1") node.getparent().replace(node, node_t) node_t.append(node) else: