From a22452a71666c015d2d77263c54f302564966818 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 24 Oct 2017 19:28:55 +0200 Subject: [PATCH] fixup! [ADD] duplicate treatment --- base_import_odoo/models/import_odoo_database.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/base_import_odoo/models/import_odoo_database.py b/base_import_odoo/models/import_odoo_database.py index c8d8ff079..6d78f80ca 100644 --- a/base_import_odoo/models/import_odoo_database.py +++ b/base_import_odoo/models/import_odoo_database.py @@ -335,10 +335,18 @@ class ImportOdooDatabase(models.Model): continue if isinstance(record, list): record = record[0] - records = model.with_context(active_test=False).search([ + domain = [ (field.name, '=', record.get(field.name)) for field in mapping.field_ids - ], limit=1) + if record.get(field.name) + ] + if len(domain) < len(mapping.field_ids): + # play it save, only use mapping if we really select + # something specific + continue + records = model.with_context(active_test=False).search( + domain, limit=1, + ) if records: _id = records.id context.idmap[(model._name, record['id'])] = _id