Skip to content
Snippets Groups Projects
Commit 01caf1e4 authored by Goffin Simon's avatar Goffin Simon
Browse files

[FIX] odoo: Import data with falsy many2one fields


Steps to reproduce:

- Export a partner with country set to False, using EXCELL
- Try to import it with the xls file

Bug:

It raised: "No matching record found for name 'False' in field 'Country' at row 2"

opw:2080376

closes odoo/odoo#38220

Signed-off-by: default avatarSimon Goffin (sig) <sig@openerp.com>
parent 530dde27
No related branches found
No related tags found
No related merge requests found
......@@ -318,6 +318,8 @@ class IrFieldsConverter(models.AbstractModel):
RelatedModel = self.env[field.comodel_name]
if subfield == '.id':
field_type = _(u"database id")
if isinstance(value, str) and not self._str_to_boolean(model, field, value)[0]:
return False, field_type, warnings
try: tentative_id = int(value)
except ValueError: tentative_id = value
try:
......@@ -332,6 +334,8 @@ class IrFieldsConverter(models.AbstractModel):
{'moreinfo': action})
elif subfield == 'id':
field_type = _(u"external id")
if not self._str_to_boolean(model, field, value)[0]:
return False, field_type, warnings
if '.' in value:
xmlid = value
else:
......@@ -340,6 +344,8 @@ class IrFieldsConverter(models.AbstractModel):
id = self.env['ir.model.data'].xmlid_to_res_id(xmlid, raise_if_not_found=False) or None
elif subfield is None:
field_type = _(u"name")
if value == '':
return False, field_type, warnings
flush()
ids = RelatedModel.name_search(name=value, operator='=')
if ids:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment