From 2ef398559459afe9afad01b0411192839acda0d4 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sat, 21 Dec 2024 20:26:33 +0100 Subject: [PATCH] [FIX] account_invoice_constraint_chronology - fix unit test --- ...t_account_invoice_constraint_chronology.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/account_invoice_constraint_chronology/tests/test_account_invoice_constraint_chronology.py b/account_invoice_constraint_chronology/tests/test_account_invoice_constraint_chronology.py index 18a73d52779..c080b88bf86 100644 --- a/account_invoice_constraint_chronology/tests/test_account_invoice_constraint_chronology.py +++ b/account_invoice_constraint_chronology/tests/test_account_invoice_constraint_chronology.py @@ -2,7 +2,7 @@ # Copyright 2021 CorporateHub (https://corporatehub.eu) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from datetime import timedelta +from datetime import date, timedelta from odoo import fields from odoo.exceptions import UserError @@ -170,11 +170,19 @@ def test_modify_invoice_date_validated_past_invoice(self): # it should be able to validate, but if we change the date # higher than YYYYYMM15 or lower than YYYYYMM05 # it should not be able to validate. - after_5_days = self.today + timedelta(days=5) - after_10_days = self.today + timedelta(days=10) - after_15_days = self.today + timedelta(days=15) - after_20_days = self.today + timedelta(days=20) - after_25_days = self.today + timedelta(days=25) + + # in order to avoid a raise caused by the sequence mixin we must ensure + # that all dates are in the same year, hence we set the invoice_1 date + # in the middle of the year + mid_year_date = date(self.today.year, 7, 1) + self.invoice_1.date = mid_year_date + self.invoice_1.invoice_date = mid_year_date + + after_5_days = mid_year_date + timedelta(days=5) + after_10_days = mid_year_date + timedelta(days=10) + after_15_days = mid_year_date + timedelta(days=15) + after_20_days = mid_year_date + timedelta(days=20) + after_25_days = mid_year_date + timedelta(days=25) self.invoice_1.action_post()