From 7c885c9fe3a1175b786a34f0952b8310ddef06d8 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 2 Sep 2016 12:02:12 +0200 Subject: [PATCH] [ADD] base: warning for external id in the wrong module Creating a external id in a different module than the one where the record is declared is a bad practice. Setting a correct module is both important for a correct uninstallation of the module (which uses the module to decide which records to remove) and for the translations (records tagged with 'base' module needs to be declared in the base.pot file). --- openerp/addons/base/ir/ir_model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index f52184a5b91..a1652323180 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -1001,6 +1001,7 @@ class IrModelData(models.Model): def _update(self, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False): # records created during module install should not display the messages of OpenChatter self = self.with_context(install_mode=True) + current_module = module if xml_id and ('.' in xml_id): assert len(xml_id.split('.')) == 2, _("'%s' contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id") % xml_id @@ -1088,6 +1089,10 @@ class IrModelData(models.Model): 'res_id': record.id, 'noupdate': noupdate }) + if current_module and module != current_module: + _logger.warning("Creating the ir.model.data %s in module %s instead of %s.", + xml_id, module, current_module) + if xml_id and record: self.loads[(module, xml_id)] = (model, record.id)