[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
This commit is contained in:
committed by
Nicolas Martinelli
parent
321486851a
commit
aed8e199ce
@@ -622,9 +622,11 @@ class Import(models.TransientModel):
|
||||
# versions, for both data and pattern
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user