Forbid payment of zero amount

Closes #13031
This commit is contained in:
Cédric Krier committed 2024-05-05 10:06:07 +02:00
1 parent 196cfbeb0c
commit ed5f91a480
3 files changed
+12 -2

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Enforce payment amount to be greater than zero
Version 7.2.0 - 2024-04-29
--------------------------
+1
View File
@@ -295,6 +295,7 @@ class Payment(Workflow, ModelSQL, ModelView):
date = fields.Date('Date', required=True, states=_STATES)
amount = Monetary(
"Amount", currency='currency', digits='currency', required=True,
domain=[('amount', '>', 0)],
states={
'readonly': ~Eval('state').in_(
If(Eval('process_method') == 'manual',
@@ -114,12 +114,20 @@ Create multiple valid payments for one line::
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = pay_line.actions[0]
>>> payment.amount
Decimal('100.00')
>>> payment.amount = Decimal('30.00')
>>> payment.save()
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = pay_line.actions[0]
>>> payment.amount
Decimal('70.00')
>>> payment.amount = Decimal('30.00')
>>> payment.save()
>>> payments = Payment.find([('state', '=', 'draft')])
>>> for payment in payments:
... payment.amount = Decimal('30')
>>> Payment.click(payments, 'submit')
Check amount to pay::