[FIX] base_import: wrong date format
Current behaviour: Wrong format used when importing dates Steps to reproduce: 1. Change your language to German 2. Go to Sales > Orders 3. Export to XLSX 4. Change to dates to german format (ie: 10.09.2023) 5. Favorites > import records > Upload file 6. Click on Test 7. "does not match format '%Y-%m-%d'" Cause of the issue: Only default formats were taken into account because options are empty. opw-3540715 closes odoo/odoo#146744 X-original-commit: bdc006a81f83efddd693a8d4f4ffaec92da36f4a Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
@@ -560,6 +560,9 @@ class Import(models.TransientModel):
|
||||
val = self._remove_currency_symbol(val)
|
||||
if val:
|
||||
if options.get('float_thousand_separator') and options.get('float_decimal_separator'):
|
||||
if options['float_decimal_separator'] == '.' and val.count('.') > 1:
|
||||
# This is not a float so exit this try
|
||||
float('a')
|
||||
val = val.replace(options['float_thousand_separator'], '').replace(options['float_decimal_separator'], '.')
|
||||
# We are now sure that this is a float, but we still need to find the
|
||||
# thousand and decimal separator
|
||||
@@ -1528,7 +1531,7 @@ class Import(models.TransientModel):
|
||||
|
||||
return input_file_data
|
||||
|
||||
_SEPARATORS = [' ', '/', '-', '']
|
||||
_SEPARATORS = [' ', '/', '-', '.', '']
|
||||
_PATTERN_BASELINE = [
|
||||
('%m', '%d', '%Y'),
|
||||
('%d', '%m', '%Y'),
|
||||
|
||||
Reference in New Issue
Block a user