Send only the required fields when fetching a readonly view definition

issue11134
review380081002
This commit is contained in:
Nicolas Évrard
2022-04-08 19:07:14 +02:00
parent 1d04f3d647
commit 742dad984e
4 changed files with 13 additions and 27 deletions
+3 -6
View File
@@ -42,16 +42,14 @@ class ConfigurationGiftCardAccount(ModelSQL, CompanyValueMixin):
('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 @@ def AccountTypeMixin(template=False):
],
states={
'invisible': Eval('statement') != 'balance',
},
depends=['statement'])
})
if not template:
for fname in dir(Mixin):
field = getattr(Mixin, fname)
+1 -2
View File
@@ -16,8 +16,7 @@ class Template(metaclass=PoolMeta):
"Gift Card",
states={
'invisible': ~Eval('type').in_(['service', 'goods']),
},
depends=['type'])
})
@fields.depends('gift_card')
def on_change_gift_card(self):
+8 -16
View File
@@ -47,8 +47,7 @@ class ConfigurationGiftCardSequence(ModelSQL, CompanyValueMixin):
('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 @@ class GiftCard(ModelSQL, ModelView):
_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 @@ class GiftCard(ModelSQL, ModelView):
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 @@ class GiftCard(ModelSQL, ModelView):
"Spent On", selection='get_spent_on', select=True, readonly=True)
del _states
del _depends
@classmethod
def __setup__(cls):
@@ -269,8 +264,7 @@ class Sale(metaclass=PoolMeta):
],
states={
'readonly': Eval('state') != 'draft',
},
depends=['state', 'company', 'currency'])
})
@classmethod
@ModelView.button
@@ -339,8 +333,7 @@ class POSSale(metaclass=PoolMeta):
],
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 @@ class _LineMixin:
states={
'invisible': ~Eval('is_gift_card_service', False),
},
depends=['is_gift_card_service'],
help="Leave empty for the customer email.")
@fields.depends('product')
+1 -3
View File
@@ -29,9 +29,7 @@ class Move(metaclass=PoolMeta):
& (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')