[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,13 +933,6 @@ class ir_model_data(osv.osv):
|
||||||
elif res_id:
|
elif res_id:
|
||||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||||
if xml_id:
|
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:
|
if model_obj._inherits:
|
||||||
for table in model_obj._inherits:
|
for table in model_obj._inherits:
|
||||||
inherit_id = model_obj.browse(cr, uid,
|
inherit_id = model_obj.browse(cr, uid,
|
||||||
|
@ -951,17 +944,17 @@ class ir_model_data(osv.osv):
|
||||||
'res_id': inherit_id.id,
|
'res_id': inherit_id.id,
|
||||||
'noupdate': noupdate,
|
'noupdate': noupdate,
|
||||||
},context=context)
|
},context=context)
|
||||||
|
self.create(cr, uid, {
|
||||||
|
'name': xml_id,
|
||||||
|
'model': model,
|
||||||
|
'module':module,
|
||||||
|
'res_id':res_id,
|
||||||
|
'noupdate': noupdate,
|
||||||
|
},context=context)
|
||||||
else:
|
else:
|
||||||
if mode=='init' or (mode=='update' and xml_id):
|
if mode=='init' or (mode=='update' and xml_id):
|
||||||
res_id = model_obj.create(cr, uid, values, context=context)
|
res_id = model_obj.create(cr, uid, values, context=context)
|
||||||
if xml_id:
|
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:
|
if model_obj._inherits:
|
||||||
for table in model_obj._inherits:
|
for table in model_obj._inherits:
|
||||||
inherit_id = model_obj.browse(cr, uid,
|
inherit_id = model_obj.browse(cr, uid,
|
||||||
|
@ -973,6 +966,13 @@ class ir_model_data(osv.osv):
|
||||||
'res_id': inherit_id.id,
|
'res_id': inherit_id.id,
|
||||||
'noupdate': noupdate,
|
'noupdate': noupdate,
|
||||||
},context=context)
|
},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:
|
if xml_id and res_id:
|
||||||
self.loads[(module, xml_id)] = (model, res_id)
|
self.loads[(module, xml_id)] = (model, res_id)
|
||||||
for table, inherit_field in model_obj._inherits.iteritems():
|
for table, inherit_field in model_obj._inherits.iteritems():
|
||||||
|
|
|
@ -482,7 +482,7 @@ class browse_record(object):
|
||||||
except KeyError, e:
|
except KeyError, e:
|
||||||
import sys
|
import sys
|
||||||
exc_info = sys.exc_info()
|
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):
|
def __contains__(self, name):
|
||||||
return (name in self._table._columns) or (name in self._table._inherit_fields) or hasattr(self._table, name)
|
return (name in self._table._columns) or (name in self._table._inherit_fields) or hasattr(self._table, name)
|
||||||
|
|
Loading…
Reference in New Issue