From 2a4bdce1a7c81db77e3e5fd0b03b77e8775db656 Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Thu, 5 Oct 2023 11:02:37 +0200 Subject: [PATCH] [FIX] account: wrong date method in account_move_send cron Switch to a datetime to avoid a wizard that has been created at 00:00 to be deleted one minute later. closes odoo/odoo#137697 X-original-commit: 128e3da4807acbc2275c7e4db3833ce062afae24 Signed-off-by: Laurent Smet (las) Signed-off-by: Claire Bretton (clbr) --- addons/account/models/account_move.py | 2 +- addons/account/tests/test_account_move_send.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 958a1209830..2d295b6e1dc 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4121,7 +4121,7 @@ class AccountMove(models.Model): ('mode', '=', 'done'), '&', ('mode', '=', 'invoice_single'), - ('create_date', '<=', fields.Date.context_today(self) - relativedelta(days=1)), + ('create_date', '<=', fields.Datetime.now() - relativedelta(hours=24)), ]).unlink() # Process. diff --git a/addons/account/tests/test_account_move_send.py b/addons/account/tests/test_account_move_send.py index 850ab19d246..ee1b4e2c3d3 100644 --- a/addons/account/tests/test_account_move_send.py +++ b/addons/account/tests/test_account_move_send.py @@ -854,7 +854,7 @@ class TestAccountMoveSend(TestAccountMoveSendCommon): self.assertTrue(wizard.exists()) # If cron is triggered one day or later than the creation it should be garbage collected. - with freeze_time(fields.Date.today() + relativedelta(days=1)): + with freeze_time(fields.Datetime.now() + relativedelta(hours=24)): self.env.ref('account.ir_cron_account_move_send').method_direct_trigger() self.assertFalse(wizard.exists())