From 1c83d4f41b093aea4f42666947d1e30acfa4d68b Mon Sep 17 00:00:00 2001 From: Thomas Beckers Date: Mon, 30 Oct 2023 10:06:39 +0000 Subject: [PATCH] [FIX] l10n_it_stock_ddt: fix comparing date and datetime Field 'date_done' is a datetime object and field 'invoice_date' is a date object. They will be considered as different even if the 'date' part is the same which is the opposite required to check if invoice is direct. >>> ddt.date_done datetime.datetime(2023, 7, 11, 10, 2, 56) >>> invoice.invoice_date datetime.date(2023, 7, 11) >>> ddt.date_done != invoice.invoice_date True This fix casts 'date_done' into a date object before comparison. >>> ddt.date_done.date() != invoice.invoice_date False opw-3571327 closes odoo/odoo#140538 X-original-commit: 87a6f398e2047b4739e27be28e75399c2ddd717f Signed-off-by: John Laterre (jol) --- addons/l10n_it_stock_ddt/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_it_stock_ddt/models/account_invoice.py b/addons/l10n_it_stock_ddt/models/account_invoice.py index a92ce368e30..b7a9eb609b4 100644 --- a/addons/l10n_it_stock_ddt/models/account_invoice.py +++ b/addons/l10n_it_stock_ddt/models/account_invoice.py @@ -24,7 +24,7 @@ class AccountMove(models.Model): def _l10n_it_edi_invoice_is_direct(self): """ An invoice is only direct if the Transport Documents are all done the same day as the invoice. """ for ddt in self.l10n_it_ddt_ids: - if not ddt.date_done or ddt.date_done != self.invoice_date: + if not ddt.date_done or ddt.date_done.date() != self.invoice_date: return False return True