summaryrefslogtreecommitdiff
path: root/addons/base_import/models
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-03-21 11:55:55 +0100
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-03-21 14:43:45 +0100
commitaed8e199ce5798dbfe8392695646fbdeb78f45f4 (patch)
tree145505265b9cb4515950990be515ae22868b9129 /addons/base_import/models
parent321486851a6e50198ea1159ae1ed3a8e53a8ebb0 (diff)
[FIX] base_import: import empty date/datetime
When a user imports a file with a datetime field set to a blank space, the value is computed as 1900-01-01 00:00:00. However, when converted in the user's TZ, this can lead to a value < 1900-01-01, which is not recognized at the JS level as a valid value. This makes the access to the record impossible, and possibly makes the access to an app impossible. It is for example the case with Purchase, where the order date is displayed on the default's action view (list view). We strip the value before testing if the value exists to avoid this case. opw-1826344
Diffstat (limited to 'addons/base_import/models')
-rw-r--r--addons/base_import/models/base_import.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py
index 83c9c76cb1e..dbff99fab88 100644
--- a/addons/base_import/models/base_import.py
+++ b/addons/base_import/models/base_import.py
@@ -623,8 +623,10 @@ class Import(models.TransientModel):
user_format = pycompat.to_native(options.get('%s_format' % field['type']))
for num, line in enumerate(data):
if line[index]:
+ line[index] = line[index].strip()
+ if line[index]:
try:
- line[index] = dt.strftime(dt.strptime(pycompat.to_native(line[index].strip()), user_format), server_format)
+ line[index] = dt.strftime(dt.strptime(pycompat.to_native(line[index]), user_format), server_format)
except ValueError as e:
raise ValueError(_("Column %s contains incorrect values. Error in line %d: %s") % (name, num + 1, e))
except Exception as e: