Modify pay button to be readonly if sale is totally paid | #161602

This commit is contained in:
Jared Esparza 2023-08-08 13:13:12 +02:00
parent 68c503039c
commit b670a30e1f
1 changed files with 9 additions and 6 deletions

15
sale.py
View File

@ -7,7 +7,7 @@ from sql.conditionals import Coalesce
from trytond.model import ModelView, fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Bool, Eval, Not
from trytond.pyson import Bool, Eval, Not, Or, Equal
from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateView, StateTransition, Button
from trytond.i18n import gettext
@ -37,11 +37,14 @@ class Sale(metaclass=PoolMeta):
def __setup__(cls):
super(Sale, cls).__setup__()
cls._buttons.update({
'wizard_sale_payment': {
'invisible': Eval('state') == 'done',
'readonly': Not(Bool(Eval('lines'))),
},
})
'wizard_sale_payment': {
'invisible': Eval('state') == 'done',
'readonly': Or(
Not(Bool(Eval('lines'))),
Equal(Eval('residual_amount', 0), 0)
),
},
})
@staticmethod
def default_sale_device():