diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py
index fefd9d9d2a3..fd397da7215 100644
--- a/odoo/addons/base/models/ir_ui_view.py
+++ b/odoo/addons/base/models/ir_ui_view.py
@@ -1986,6 +1986,9 @@ actual arch.
return any(
(attr in ('data-oe-model', 'groups') or (attr.startswith('t-')))
for attr in node.attrib
+ ) or (
+ node.tag is etree.ProcessingInstruction
+ and node.target == 'apply-inheritance-specs-node-removal'
)
@api.model
diff --git a/odoo/addons/base/tests/test_views.py b/odoo/addons/base/tests/test_views.py
index 7ad8a1f9442..12d2e887752 100644
--- a/odoo/addons/base/tests/test_views.py
+++ b/odoo/addons/base/tests/test_views.py
@@ -908,6 +908,48 @@ class TestTemplating(ViewCase):
initial.get('data-oe-xpath'),
"The node's xpath position should be correct")
+ def test_branding_inherit_remove_node2(self):
+ view1 = self.View.create({
+ 'name': "Base view",
+ 'type': 'qweb',
+ 'arch': """
+
+
+
+
+ """
+ })
+ self.View.create({
+ 'name': "Extension",
+ 'type': 'qweb',
+ 'inherit_id': view1.id,
+ 'arch': """
+
+
+
+ """
+ })
+
+ arch_string = view1.with_context(inherit_branding=True).get_combined_arch()
+
+ arch = etree.fromstring(arch_string)
+ self.View.distribute_branding(arch)
+
+ # Note: this test is a variant of the test_branding_inherit_remove_node
+ # -> in this case, we expect the branding to not be distributed on the
+ # element anymore but on the only remaining world.
+ [initial] = arch.xpath('/hello[1]')
+ self.assertIsNone(
+ initial.get('data-oe-model'),
+ "The inner content of the root was xpath'ed, it should not receive branding anymore")
+
+ # Only remaining world but still the second in original view
+ [initial] = arch.xpath('/hello[1]/world[1]')
+ self.assertEqual(
+ '/hello[1]/world[2]',
+ initial.get('data-oe-xpath'),
+ "The node's xpath position should be correct")
+
def test_branding_inherit_top_t_field(self):
view1 = self.View.create({
'name': "Base view",