[FIX] base_import: Specified Date Format in Import Statment is not recognized
Steps to reproduce the bug: 1. Import a bank statement with the shown dateformad DDMMYYYY (without headers) 2. Specify this date format in the advanced options 3. Try to find the date column to assign. Bug: The date format is not suggested for the fields with format DDMMYYYY. opw:769118
This commit is contained in:
@@ -305,6 +305,8 @@ class Import(models.TransientModel):
|
||||
if all(val.lower() in ('true', 'false', 't', 'f', '') for val in preview_values):
|
||||
return ['boolean']
|
||||
# If all values can be cast to float, type is either float or monetary
|
||||
# Or a date/datetime if it matches the pattern
|
||||
results = []
|
||||
try:
|
||||
thousand_separator = decimal_separator = False
|
||||
for val in preview_values:
|
||||
@@ -336,7 +338,7 @@ class Import(models.TransientModel):
|
||||
if thousand_separator and not options.get('float_decimal_separator'):
|
||||
options['float_thousand_separator'] = thousand_separator
|
||||
options['float_decimal_separator'] = decimal_separator
|
||||
return ['float', 'monetary']
|
||||
results = ['float', 'monetary']
|
||||
except ValueError:
|
||||
pass
|
||||
# Try to see if all values are a date or datetime
|
||||
@@ -372,13 +374,15 @@ class Import(models.TransientModel):
|
||||
current_date_pattern = check_patterns(date_patterns, preview_values)
|
||||
if current_date_pattern:
|
||||
options['date_format'] = current_date_pattern
|
||||
return ['date']
|
||||
results += ['date']
|
||||
|
||||
current_datetime_pattern = check_patterns(datetime_patterns, preview_values)
|
||||
if current_datetime_pattern:
|
||||
options['datetime_format'] = current_datetime_pattern
|
||||
return ['datetime']
|
||||
results += ['datetime']
|
||||
|
||||
if results:
|
||||
return results
|
||||
return ['text', 'char', 'datetime', 'selection', 'many2one', 'one2many', 'many2many', 'html']
|
||||
|
||||
@api.model
|
||||
@@ -500,7 +504,7 @@ class Import(models.TransientModel):
|
||||
'headers_type': header_types or False,
|
||||
'preview': preview,
|
||||
'options': options,
|
||||
'advanced_mode': any([len(models.fix_import_export_id_paths(col)) > 1 for col in headers]),
|
||||
'advanced_mode': any([len(models.fix_import_export_id_paths(col)) > 1 for col in headers or []]),
|
||||
'debug': self.user_has_groups('base.group_no_one'),
|
||||
}
|
||||
except Exception, error:
|
||||
|
||||
Reference in New Issue
Block a user