Skip to content

Commit 5669952

Browse files
committed
[FIX] account_payment_pro: remove state from constraint on to_pay_move_line_ids
Allow resetting to draft when a payment has inconsistent 'to_pay_move_line_ids' that were previously modified. Removing 'state' from the constraint dependencies prevents validation errors during the 'reset to draft' flow of an invoice. This issue occurs when to pay move lines initially created with the payment's account are later modified to a different account. By removing the state trigger, we avoid re-validating account consistency during state transitions that don't involve line modifications. Steps to Reproduce 1. Create and Post an Invoice: 2. Register a Payment with multiple To Pay move lines: Click on Register Payment from the invoice. 3. Manually Modify an un-reconciled To Pay move line: Exaple: Change the Account of this specific line to a different one (e.g., from "Receivable" to "Other Current Assets"). 4.Go back to the original Invoice (the one reconciled with the payment). 5. Click the Reset to Draft button. closes #967 Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
1 parent c91be66 commit 5669952

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

account_payment_pro/models/account_payment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _compute_write_off_available(self):
150150
rec.env["account.write_off.type"].search([("company_ids", "=", rec.company_id.id)], limit=1)
151151
)
152152

153-
@api.constrains("to_pay_move_line_ids", "state")
153+
@api.constrains("to_pay_move_line_ids")
154154
def _check_to_pay_lines_account(self):
155155
"""TODO ver si esto tmb lo llevamos a la UI y lo mostramos como un warning.
156156
tmb podemos dar mas info al usuario en el error"""
@@ -662,6 +662,7 @@ def _reconcile_after_post(self):
662662

663663
def action_post(self):
664664
res = super().action_post()
665+
self._check_to_pay_lines_account()
665666
self._reconcile_after_post()
666667
return res
667668

0 commit comments

Comments
 (0)