[FIX] mail: remove microseconds when parsing vague datetime
Mail holds an helper function to convert datetime from a char input into a
datetime value. It is used notably when having to store a datetime value
(e.g. on a mail_mail) from a string generated by templates with expression
like ``{{ datetime.datetime.now() + datetime.timedelta(days=2)}}``.
In this commit we explicitly remove microseconds, as otherwise we end up with
something that the web client cannot parse, not speaking of even going into
server side storage with this value not matching the expected format.
Task-2710804 (Mail: Clean MailThread Posting API)
Part-of: odoo/odoo#99482
This commit is contained in:
@@ -309,6 +309,7 @@ class MailMail(models.Model):
|
||||
except (ValueError, TypeError):
|
||||
parsed_datetime = False
|
||||
if parsed_datetime:
|
||||
parsed_datetime = parsed_datetime.replace(microsecond=0)
|
||||
if not parsed_datetime.tzinfo:
|
||||
parsed_datetime = pytz.utc.localize(parsed_datetime)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user