From d93148240b9149fd222eed30e04a0e151a1697c4 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 18 Mar 2015 12:44:44 +0100 Subject: [PATCH] [FIX] ir.model.data: update_dummy should mark `inherits` parents too When a `noupdate` record is processed during an update, the update_dummy method marks the record as "seen" so it won't be deleted at the garbage collection step, and seen as an obsolete external ID. This needs to be done also for the parent records via _inherits, because they have also received an implicit external ID at creation, and must not be garbage collected, even if their `noupdate` flag (db side) is not set because the flag was added later. This rare problem could be reproduced by creating a product in a module, then referencing it in e.g. a sales order, then updating the module after changing the product record to be in a `noupdate` block. At the end of the update the implicit product.template record would be garbage collected, and trigger a cascade deletion of its children - blocked by the SO reference to the product. --- openerp/addons/base/ir/ir_model.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 282d76d7ef0..e488515b09a 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -992,6 +992,10 @@ class ir_model_data(osv.osv): if record: id = record.id self.loads[(module,xml_id)] = (model,id) + for table, inherit_field in self.pool[model]._inherits.iteritems(): + parent_id = record[inherit_field].id + parent_xid = '%s_%s' % (xml_id, table.replace('.', '_')) + self.loads[(module, parent_xid)] = (table, parent_id) except Exception: pass return id