From 03e0455e755670bf7332fe692b4e7ec68cbf3b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 14 Jul 2023 12:01:05 +0200 Subject: [PATCH] Do not allow overpayment of invoice when write-off amount is negative When paying less than the amount to pay, there is no overpayment. --- modules/account_invoice/invoice.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 1affedd46d..2a99154b1c 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -3157,7 +3157,12 @@ class PayInvoiceAsk(ModelView): ('writeoff', "Write-Off"), ('partial', "Partial Payment"), ('overpayment', "Overpayment"), - ], 'Type', required=True) + ], 'Type', required=True, + domain=[ + If(Eval('amount_writeoff', 0) >= 0, + ('type', 'in', ['writeoff', 'partial']), + ()), + ]) writeoff = fields.Many2One( 'account.move.reconcile.write_off', "Write Off", domain=[