changeset 8a8af20ea329 in modules/sale_gift_card:default details: https://hg.tryton.org/modules/sale_gift_card?cmd=changeset&node=8a8af20ea329 description: Send only the required fields when fetching a readonly view definition
issue11134 review380081002 diffstat: account.py | 9 +++------ product.py | 3 +-- sale.py | 24 ++++++++---------------- stock.py | 4 +--- 4 files changed, 13 insertions(+), 27 deletions(-) diffs (141 lines): diff -r 92e0d5732427 -r 8a8af20ea329 account.py --- a/account.py Wed Apr 06 23:37:43 2022 +0200 +++ b/account.py Fri Apr 08 19:07:14 2022 +0200 @@ -42,16 +42,14 @@ ('type.gift_card', '=', True), ('closed', '!=', True), ('company', '=', Eval('company', -1)), - ], - depends=['company']) + ]) gift_card_account_revenue = fields.Many2One( 'account.account', "Gift Card Revenue", domain=[ ('type.gift_card', '=', True), ('closed', '!=', True), ('company', '=', Eval('company', -1)), - ], - depends=['company']) + ]) def AccountTypeMixin(template=False): @@ -66,8 +64,7 @@ ], states={ 'invisible': Eval('statement') != 'balance', - }, - depends=['statement']) + }) if not template: for fname in dir(Mixin): field = getattr(Mixin, fname) diff -r 92e0d5732427 -r 8a8af20ea329 product.py --- a/product.py Wed Apr 06 23:37:43 2022 +0200 +++ b/product.py Fri Apr 08 19:07:14 2022 +0200 @@ -16,8 +16,7 @@ "Gift Card", states={ 'invisible': ~Eval('type').in_(['service', 'goods']), - }, - depends=['type']) + }) @fields.depends('gift_card') def on_change_gift_card(self): diff -r 92e0d5732427 -r 8a8af20ea329 sale.py --- a/sale.py Wed Apr 06 23:37:43 2022 +0200 +++ b/sale.py Fri Apr 08 19:07:14 2022 +0200 @@ -47,8 +47,7 @@ ('company', 'in', [Eval('company', -1), None]), ('sequence_type', '=', Id( 'sale_gift_card', 'sequence_type_gift_card')), - ], - depends=['company']) + ]) class GiftCard(ModelSQL, ModelView): @@ -59,13 +58,11 @@ _states = { 'readonly': Bool(Eval('origin')) | Bool(Eval('spent_on')), } - _depends = ['origin'] number = fields.Char( - "Number", required=True, states=_states, depends=_depends) + "Number", required=True, states=_states) company = fields.Many2One( - 'company.company', "Company", required=True, - states=_states, depends=_depends) + 'company.company', "Company", required=True, states=_states) product = fields.Many2One( 'product.product', "Product", required=True, domain=[ @@ -74,13 +71,12 @@ context={ 'company': Eval('company', -1), }, - states=_states, depends=_depends + ['company']) + states=_states, depends={'company'}) value = Monetary( "Value", currency='currency', digits='currency', required=True, - states=_states, depends=_depends) + states=_states) currency = fields.Many2One( - 'currency.currency', "Currency", required=True, - states=_states, depends=_depends) + 'currency.currency', "Currency", required=True, states=_states) origin = fields.Reference( "Origin", selection='get_origin', select=True, readonly=True) @@ -88,7 +84,6 @@ "Spent On", selection='get_spent_on', select=True, readonly=True) del _states - del _depends @classmethod def __setup__(cls): @@ -269,8 +264,7 @@ ], states={ 'readonly': Eval('state') != 'draft', - }, - depends=['state', 'company', 'currency']) + }) @classmethod @ModelView.button @@ -339,8 +333,7 @@ ], states={ 'readonly': Eval('state') != 'draft', - }, - depends=['state', 'company', 'currency']) + }) @fields.depends('state', 'gift_cards') def on_change_with_total(self, name=None): @@ -410,7 +403,6 @@ states={ 'invisible': ~Eval('is_gift_card_service', False), }, - depends=['is_gift_card_service'], help="Leave empty for the customer email.") @fields.depends('product') diff -r 92e0d5732427 -r 8a8af20ea329 stock.py --- a/stock.py Wed Apr 06 23:37:43 2022 +0200 +++ b/stock.py Fri Apr 08 19:07:14 2022 +0200 @@ -29,9 +29,7 @@ & (Eval('state') == 'done')), 'readonly': Eval('state').in_(['cancel', 'done']), }, - depends=[ - 'gift_cards_required', 'internal_quantity', 'company', 'product', - 'state']) + depends={'internal_quantity'}) gift_cards_required = fields.Function( fields.Boolean("Gift Cards Required"), 'on_change_with_gift_cards_required')