I have an Odoo server, where the instance have the following condition and date.today()
return yesterday. the following condition return true:
if invoice.invoice_date > date.today():
errors.append("- Please, make sure the invoice date is set to either the same as or before Today.")
however, using the python shell in the same pc it returns the correct date. please, note that the time was Feb 24 1:20 AM and both python in the same environment.
so, could you let me know if python date.today()
could be affect by any context
?
Odoo date are stored as UTC. As specified in datetime documentation, today return the local current date, that could be the cause of your problem. You should read about naive and aware date. https://docs.python.org/3/library/datetime.html#aware-and-naive-objects hope it's help