[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:
parent
6a696ba673
commit
067cd7d15a
|
@ -933,6 +933,17 @@ class ir_model_data(osv.osv):
|
|||
elif res_id:
|
||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||
if xml_id:
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
res_id,context=context)[model_obj._inherits[table]]
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id.id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
|
@ -940,6 +951,10 @@ class ir_model_data(osv.osv):
|
|||
'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:
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
|
@ -951,10 +966,6 @@ class ir_model_data(osv.osv):
|
|||
'res_id': inherit_id.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,
|
||||
|
@ -962,17 +973,6 @@ class ir_model_data(osv.osv):
|
|||
'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,
|
||||
res_id,context=context)[model_obj._inherits[table]]
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id.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():
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue