mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] account_invoice_constraint_chronology: modify past invoices
Addresses the issue as commented here: - https://github.com/OCA/account-financial-tools/issues/1206 - https://github.com/OCA/account-financial-tools/pull/1152#issuecomment-847854629 Summary of the steps to reproduce the problem: 1. Set on the invoices journal the constraint chronology. 2. Validate an invoice for this journal today. 3. Your accountant says there's an error on an invoice from yesterday. 4. Cancel it an set it to draft. You don't even need to modify anything 5. Try to post the invoice. 6. You'll get a chronology error. In v12 this was considered but it was lost on the migration to v13:800c02474e/account_invoice_constraint_chronology/model/account_invoice.py (L50)800c02474e/account_invoice_constraint_chronology/model/account_invoice.py (L70-L73)TT34624
This commit is contained in:
@@ -94,7 +94,7 @@ class AccountMove(models.Model):
|
||||
def write(self, vals):
|
||||
if vals.get("state") != "posted":
|
||||
return super().write(vals)
|
||||
|
||||
previously_validated = self.filtered(lambda m: m.name and m.name != "/")
|
||||
newly_posted = self.filtered(lambda move: move.state != "posted")
|
||||
res = super().write(vals)
|
||||
for move in newly_posted & self.filtered("journal_id.check_chronology"):
|
||||
@@ -104,6 +104,8 @@ class AccountMove(models.Model):
|
||||
move._raise_sequence_ordering_conflict()
|
||||
if self.search(move._get_older_conflicting_invoices_domain(), limit=1):
|
||||
move._raise_older_conflicting_invoices()
|
||||
if move in previously_validated:
|
||||
continue
|
||||
if self.search(move._get_newer_conflicting_invoices_domain(), limit=1):
|
||||
move._raise_newer_conflicting_invoices()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user