From acafe2af9dd1ced440db02eca900cf743891774b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 21 Dec 2016 23:11:22 +0100 Subject: [PATCH] Disable with_refund when it is not available This provides a better user experience than raising an error message. issue6112 review34521002 --- invoice.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/invoice.py b/invoice.py index ed6ca1ecc6..1369deaa11 100644 --- a/invoice.py +++ b/invoice.py @@ -2640,7 +2640,12 @@ class CreditInvoiceStart(ModelView): 'Credit Invoice' __name__ = 'account.invoice.credit.start' with_refund = fields.Boolean('With Refund', + states={ + 'readonly': ~Eval('with_refund_allowed'), + }, + depends=['with_refund_allowed'], help='If true, the current invoice(s) will be paid.') + with_refund_allowed = fields.Boolean("With Refund Allowed", readonly=True) class CreditInvoice(Wizard): @@ -2670,12 +2675,14 @@ class CreditInvoice(Wizard): Invoice = Pool().get('account.invoice') default = { 'with_refund': True, + 'with_refund_allowed': True, } for invoice in Invoice.browse(Transaction().context['active_ids']): if (invoice.state != 'posted' or invoice.payment_lines or invoice.type == 'in'): default['with_refund'] = False + default['with_refund_allowed'] = False break return default