[FIX] ir_model_data: create the _inherits parent external ID prior to the child.

This is needed so the uninstall process can simply go through
the installed data by using the ir_model_data entries in reverse
order (when ordered by IDs), so that parents are deleted before
children.

bzr revid: vmt@openerp.com-20130321133202-igea1vxlszfpk6pe
This commit is contained in:
Vo Minh Thu 2013-03-21 14:32:02 +01:00
parent 6a696ba673
commit 067cd7d15a
2 changed files with 15 additions and 15 deletions

View File

@ -933,13 +933,6 @@ class ir_model_data(osv.osv):
elif res_id:
model_obj.write(cr, uid, [res_id], values, context=context)
if xml_id:
self.create(cr, uid, {
'name': xml_id,
'model': model,
'module':module,
'res_id':res_id,
'noupdate': noupdate,
},context=context)
if model_obj._inherits:
for table in model_obj._inherits:
inherit_id = model_obj.browse(cr, uid,
@ -951,17 +944,17 @@ class ir_model_data(osv.osv):
'res_id': inherit_id.id,
'noupdate': noupdate,
},context=context)
self.create(cr, uid, {
'name': xml_id,
'model': model,
'module':module,
'res_id':res_id,
'noupdate': noupdate,
},context=context)
else:
if mode=='init' or (mode=='update' and xml_id):
res_id = model_obj.create(cr, uid, values, context=context)
if xml_id:
self.create(cr, uid, {
'name': xml_id,
'model': model,
'module': module,
'res_id': res_id,
'noupdate': noupdate
},context=context)
if model_obj._inherits:
for table in model_obj._inherits:
inherit_id = model_obj.browse(cr, uid,
@ -973,6 +966,13 @@ class ir_model_data(osv.osv):
'res_id': inherit_id.id,
'noupdate': noupdate,
},context=context)
self.create(cr, uid, {
'name': xml_id,
'model': model,
'module': module,
'res_id': res_id,
'noupdate': noupdate
},context=context)
if xml_id and res_id:
self.loads[(module, xml_id)] = (model, res_id)
for table, inherit_field in model_obj._inherits.iteritems():

View File

@ -482,7 +482,7 @@ class browse_record(object):
except KeyError, e:
import sys
exc_info = sys.exc_info()
raise AttributeError, "Got %r while trying to get attribute `%s`." % (e, name), exc_info[2]
raise AttributeError, "Got %r while trying to get attribute %s on a %s record." % (e, name, self._table._name), exc_info[2]
def __contains__(self, name):
return (name in self._table._columns) or (name in self._table._inherit_fields) or hasattr(self._table, name)