From 5a1326757b47925c2051cb90c1badf9d34e92a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 11 Sep 2024 20:11:31 +0200 Subject: [PATCH] [FIX] account_invoice_constraint_chronology: fix issue with already numbered invoice An already numbered invoice should not conflict with future draft invoices named /. --- .../model/account_move.py | 2 ++ .../tests/test_account_invoice_constraint_chronology.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/account_invoice_constraint_chronology/model/account_move.py b/account_invoice_constraint_chronology/model/account_move.py index 8829254c8cf..f9c005551a9 100644 --- a/account_invoice_constraint_chronology/model/account_move.py +++ b/account_invoice_constraint_chronology/model/account_move.py @@ -96,6 +96,7 @@ def _conflicting_inv_after_sequence_before_inv_date_domain(self): [ ( ("name", ">", self.name), + ("name", "!=", "/"), ("invoice_date", "<", self.invoice_date), ) ] @@ -106,6 +107,7 @@ def _conflicting_inv_before_sequence_after_inv_date_domain(self): [ ( ("name", "<", self.name), + ("name", "!=", "/"), ("invoice_date", ">", self.invoice_date), ) ] 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..66da6f73d1b 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 @@ -225,3 +225,12 @@ def test_modify_invoice_date_validated_past_invoice(self): ), ): self.invoice_1_a_15.action_post() + + def test_post_invoice_with_name(self): + # invoice 1 has a number (not /) + assert self.invoice_1.state == "draft" + assert self.invoice_1.name > "/" + # invoice 2 is dated after invoice 1 and is named '/' + invoice2 = self.invoice_1.copy() + invoice2.invoice_date = self.invoice_1.invoice_date + timedelta(days=1) + self.invoice_1.action_post()