[FIX] views inheritance: deleting a non-existing attribute must be a no-op

bzr revid: chs@openerp.com-20131108175750-yenql6hycpn95i9j
This commit is contained in:
Christophe Simonis 2013-11-08 18:57:50 +01:00
parent 86fea1e176
commit d67ff9ba02
2 changed files with 15 additions and 2 deletions

View File

@ -40,6 +40,19 @@ class test_views(common.TransactionCase):
""",
})
def test_20_remove_unexisting_attribute(self):
Views = self.registry('ir.ui.view')
Views.create(self.cr, self.uid, {
'name': 'Test View',
'model': 'ir.ui.view',
'inherit_id': self.browse_ref('base.view_view_tree').id,
'arch': """<?xml version="1.0"?>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="non_existing_attribute"></attribute>
</xpath>
""",
})
def _insert_view(self, **kw):
"""Insert view into database via a query to passtrough validation"""
kw.pop('id', None)

View File

@ -2153,8 +2153,8 @@ class BaseModel(object):
attribute = (child.get('name'), child.text and child.text.encode('utf8') or None)
if attribute[1]:
node.set(attribute[0], attribute[1])
else:
del(node.attrib[attribute[0]])
elif attribute[0] in node.attrib:
del node.attrib[attribute[0]]
else:
sib = node.getnext()
for child in spec: