[IMP] ir.model.data: sanity check to help prevent external IDs conflict between models

bzr revid: odo@openerp.com-20111013163316-gjct0pyrxfz9bm45
This commit is contained in:
Olivier Dony 2011-10-13 18:33:16 +02:00
parent 8a7c61cb96
commit 462f808500
1 changed files with 4 additions and 2 deletions

View File

@ -671,18 +671,20 @@ class ir_model_data(osv.osv):
action_id = False
if xml_id:
cr.execute('''SELECT imd.id, imd.res_id, md.id
cr.execute('''SELECT imd.id, imd.res_id, md.id, imd.model
FROM ir_model_data imd LEFT JOIN %s md ON (imd.res_id = md.id)
WHERE imd.module=%%s AND imd.name=%%s''' % model_obj._table,
(module, xml_id))
results = cr.fetchall()
for imd_id2,res_id2,real_id2 in results:
for imd_id2,res_id2,real_id2,real_model in results:
if not real_id2:
self._get_id.clear_cache(self, uid, module, xml_id)
self.get_object_reference.clear_cache(self, uid, module, xml_id)
cr.execute('delete from ir_model_data where id=%s', (imd_id2,))
res_id = False
else:
assert model == real_model, "External ID conflict, %s already refers to a `%s` record,"\
" you can't define a `%s` record with this ID." % (xml_id, real_model, model)
res_id,action_id = res_id2,imd_id2
if action_id and res_id: