From ff915dd96e187e128e7cf0982009401b67703651 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 8 Feb 2016 16:47:20 +0100 Subject: [PATCH] [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 --- openerp/addons/base/ir/ir_model.py | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 137f912e164..01077356ffe 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -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: