[FIX] base_import: prioritise field name over string
When importing csv data, the column name is matched on the field name and string attribute. For some fields (e.g. name & display_name), you could get a match on both the string and technical field name for different fields The order of the fields is not deterministic as stored in a dictionnary so different results were possible at different import. The technical name should be prioritised (more stable, unique constraint). Fixes #6657
This commit is contained in:
parent
5a10903e9b
commit
245b5afcfd
|
@ -158,12 +158,19 @@ class ir_import(orm.TransientModel):
|
|||
all the fields to traverse
|
||||
:rtype: list(Field)
|
||||
"""
|
||||
string_match = None
|
||||
for field in fields:
|
||||
# FIXME: should match all translations & original
|
||||
# TODO: use string distance (levenshtein? hamming?)
|
||||
if header.lower() == field['name'].lower() \
|
||||
or header.lower() == field['string'].lower():
|
||||
if header.lower() == field['name'].lower():
|
||||
return [field]
|
||||
if header.lower() == field['string'].lower():
|
||||
# matching string are not reliable way because
|
||||
# strings have no unique constraint
|
||||
string_match = field
|
||||
if string_match:
|
||||
# this behavior is only applied if there is no matching field['name']
|
||||
return [string_match]
|
||||
|
||||
if '/' not in header:
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue