[FIX] models: restore warning on wrong record
Was lost during d5b687a48f
Set the module name in the context to be able to detect errors in xml and csv import
closes odoo/odoo#27680
This commit is contained in:
committed by
Raphael Collet
parent
de265ce63e
commit
933165ec3a
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user