summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2018-10-11 12:11:19 +0000
committerRaphael Collet <rco@odoo.com>2018-10-21 08:41:22 +0000
commit933165ec3afa0676de4b2f3662c4c1bb2f97efc5 (patch)
treebea8ef0c5fe5322f54a4f99f68d5efa101d23cf7
parentde265ce63e0c93df99c710d46b8233b07c6c7c14 (diff)
[FIX] models: restore warning on wrong record
Was lost during d5b687a48ffb Set the module name in the context to be able to detect errors in xml and csv import closes odoo/odoo#27680
-rw-r--r--odoo/models.py8
-rw-r--r--odoo/tools/convert.py2
2 files changed, 10 insertions, 0 deletions
diff --git a/odoo/models.py b/odoo/models.py
index fe3a9dd4781..ce3bfdee9b6 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -3791,6 +3791,14 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
else:
imd.browse(d_id).unlink()
+ # check for records to create with an XMLID from another module
+ module = self.env.context.get('install_module')
+ if module:
+ prefix = module + "."
+ for data in to_create:
+ if data.get('xml_id') and not data['xml_id'].startswith(prefix):
+ _logger.warning("Creating record %s in module %s.", data['xml_id'], module)
+
# create records
records = self.create([data['values'] for data in to_create])
for data, record in pycompat.izip(to_create, records):
diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py
index a9a3796a34a..b98e586a62e 100644
--- a/odoo/tools/convert.py
+++ b/odoo/tools/convert.py
@@ -832,6 +832,8 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
context = {
'mode': mode,
'module': module,
+ 'install_module': module,
+ 'install_filename': fname,
'noupdate': noupdate,
}
env = odoo.api.Environment(cr, SUPERUSER_ID, context)