diff --git a/modules/account_payment/CHANGELOG b/modules/account_payment/CHANGELOG index eba650a0b8..714f6a13bf 100644 --- a/modules/account_payment/CHANGELOG +++ b/modules/account_payment/CHANGELOG @@ -1,3 +1,4 @@ +* Enforce payment amount to be greater than zero Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/account_payment/payment.py b/modules/account_payment/payment.py index 54cdb6c35f..a7fae0de18 100644 --- a/modules/account_payment/payment.py +++ b/modules/account_payment/payment.py @@ -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', diff --git a/modules/account_payment/tests/scenario_account_payment_invoice.rst b/modules/account_payment/tests/scenario_account_payment_invoice.rst index 8f4b9a78bb..00e901cba3 100644 --- a/modules/account_payment/tests/scenario_account_payment_invoice.rst +++ b/modules/account_payment/tests/scenario_account_payment_invoice.rst @@ -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::