From 8b61103f5ef7bcff8b2174f36acaddabfe07dd3d Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sat, 21 Dec 2024 20:26:33 +0100 Subject: [PATCH 1/2] [FIX] account_invoice_constraint_chronology - fix unit test --- .../tests/test_account_invoice_constraint_chronology.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 18a73d527..7809f4f5e 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,13 +2,19 @@ # 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 freezegun import freeze_time from odoo import fields from odoo.exceptions import UserError from odoo.tests import common +# in order to avoid a raise caused by the sequence mixin we must ensure +# that all dates are in the same year, hence we freeze the date +# in the middle of the year +@freeze_time(f"{date.today().year}-07-01") class TestAccountInvoiceConstraintChronology(common.TransactionCase): @classmethod def setUpClass(cls): From 69444e6bdbcb9e181e5085c24f6fbb879b6e6d06 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Mon, 23 Dec 2024 13:06:42 +0100 Subject: [PATCH 2/2] [FIX] account_invoice_constraint_chronology: fix unit test conflict with demo data --- ...t_account_invoice_constraint_chronology.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 7809f4f5e..99c99a059 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 @@ -176,6 +176,25 @@ class TestAccountInvoiceConstraintChronology(common.TransactionCase): # 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. + + # FIX conflict between 'freeze_time' and account module demo data + conflicting_invoices = self.env["account.move"] + conflicting_names = [ + "demo_invoice_1", + "demo_invoice_2", + "demo_invoice_3", + "demo_invoice_followup", + "demo_invoice_5", + ] + for name in conflicting_names: + conflicting_invoices += self.env.ref( + f"account.{self.env.company.id}_{name}" + ) + conflicting_invoices.button_draft() + conflicting_invoices.write( + {"name": False, "invoice_date": date.today().replace(day=1)} + ) + after_5_days = self.today + timedelta(days=5) after_10_days = self.today + timedelta(days=10) after_15_days = self.today + timedelta(days=15)