From 740bf28907d97db8dbc8628e4746e1d17d8a95b9 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sat, 24 Jan 2015 00:15:22 +0100 Subject: [PATCH] [FIX] ir.model.data: verify record exists in _update_dummy When a stale XML ID exists in the database, `_update_dummy()` must consider it as missing entirely, and the next call to `_update()` will take care of cleaning up the old XML ID. Failing to do so for `noupdate` records means the `_update` will never happen, and as soon as another record is created or updated with a relationship to that stale XML ID, it will plainly crash the installation/update. --- openerp/addons/base/ir/ir_model.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 579178c36cb..abd43777155 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -985,11 +985,15 @@ class ir_model_data(osv.osv): def _update_dummy(self,cr, uid, model, module, xml_id=False, store=True): if not xml_id: return False + id = False try: - id = self.read(cr, uid, [self._get_id(cr, uid, module, xml_id)], ['res_id'])[0]['res_id'] - self.loads[(module,xml_id)] = (model,id) - except: - id = False + # One step to check the ID is defined and the record actually exists + record = self.get_object(cr, uid, module, xml_id) + if record: + id = record.id + self.loads[(module,xml_id)] = (model,id) + except Exception: + pass return id def clear_caches(self):