Skip to content

Commit ca57806

Browse files
committed
[IMP] account_invoice_constraint_chronology: better message
The error message in case of an older conflicting invoice was not really helpful. Now it will show the conflicting invoice name if any and also the customer name (because a draft invoice will likely be named '/' so just the name might not be enough). This will help the user to find the offending invoice. It also suggest to removed the invoice date as a possible work around.
1 parent 2803271 commit ca57806

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

account_invoice_constraint_chronology/model/account_move.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ def _get_older_conflicting_invoices_domain(self):
3434
]
3535
)
3636

37-
def _raise_older_conflicting_invoices(self):
37+
def _raise_older_conflicting_invoices(self, older_move):
3838
self.ensure_one()
3939
raise UserError(
4040
_(
41-
"Chronology conflict: A conflicting draft invoice dated before "
42-
"{date_invoice} exists, please validate it first."
43-
).format(date_invoice=format_date(self.env, self.invoice_date))
41+
"Chronology conflict: A conflicting draft invoice {name} for "
42+
"{partner} dated before {date_invoice} exists, please validate it "
43+
"first or remove its invoice date."
44+
).format(
45+
date_invoice=format_date(self.env, self.invoice_date),
46+
name=older_move.name,
47+
partner=older_move.partner_id.name,
48+
)
4449
)
4550

4651
def _get_newer_conflicting_invoices_domain(self):
@@ -160,8 +165,11 @@ def write(self, vals):
160165
move._get_sequence_order_conflicting_invoices_domain(), limit=1
161166
):
162167
move._raise_sequence_ordering_conflict()
163-
if self.search(move._get_older_conflicting_invoices_domain(), limit=1):
164-
move._raise_older_conflicting_invoices()
168+
older_move = self.search(
169+
move._get_older_conflicting_invoices_domain(), limit=1
170+
)
171+
if older_move:
172+
move._raise_older_conflicting_invoices(older_move)
165173
if move in previously_validated:
166174
if self.search(
167175
move._get_sequence_order_conflicting_previously_validated(), limit=1

0 commit comments

Comments
 (0)