[FIX] import: import new records without xml_ids
This is related to revision 80b373f
.
The above revision leads to the inability
to import new records without any `xml_id` set
Technically speaking, this is because
you cannot concatenate `False` with `'_'`, in
`xml_id + '_'`
opw-668962
This commit is contained in:
parent
3ff4dae5b0
commit
ff915dd96e
|
@ -1044,22 +1044,23 @@ class ir_model_data(osv.osv):
|
|||
else:
|
||||
if mode=='init' or (mode=='update' and xml_id):
|
||||
inherit_xml_ids = []
|
||||
for table, field_name in model_obj._inherits.items():
|
||||
xml_ids = self.pool['ir.model.data'].search(cr, uid, [
|
||||
('module', '=', module),
|
||||
('name', '=', xml_id + '_' + table.replace('.', '_')),
|
||||
], context=context)
|
||||
# XML ID found in the database, try to recover an existing record
|
||||
if xml_ids:
|
||||
found_xml_id = self.pool['ir.model.data'].browse(cr, uid, xml_ids[0], context=context)
|
||||
record = self.pool[found_xml_id.model].browse(cr, uid, [found_xml_id.res_id], context=context)[0]
|
||||
# The record exists, store the id and don't recreate the XML ID
|
||||
if record.exists():
|
||||
inherit_xml_ids.append(found_xml_id.model)
|
||||
values[field_name] = found_xml_id.res_id
|
||||
# Orphan XML ID, delete it
|
||||
else:
|
||||
found_xml_id.unlink()
|
||||
if xml_id:
|
||||
for table, field_name in model_obj._inherits.items():
|
||||
xml_ids = self.pool['ir.model.data'].search(cr, uid, [
|
||||
('module', '=', module),
|
||||
('name', '=', xml_id + '_' + table.replace('.', '_')),
|
||||
], context=context)
|
||||
# XML ID found in the database, try to recover an existing record
|
||||
if xml_ids:
|
||||
found_xml_id = self.pool['ir.model.data'].browse(cr, uid, xml_ids[0], context=context)
|
||||
record = self.pool[found_xml_id.model].browse(cr, uid, [found_xml_id.res_id], context=context)[0]
|
||||
# The record exists, store the id and don't recreate the XML ID
|
||||
if record.exists():
|
||||
inherit_xml_ids.append(found_xml_id.model)
|
||||
values[field_name] = found_xml_id.res_id
|
||||
# Orphan XML ID, delete it
|
||||
else:
|
||||
found_xml_id.unlink()
|
||||
|
||||
res_id = model_obj.create(cr, uid, values, context=context)
|
||||
if xml_id:
|
||||
|
|
Loading…
Reference in New Issue