changeset 602bf5696bd5 in modules/customs:default
details: https://hg.tryton.org/modules/customs?cmd=changeset&node=602bf5696bd5
description:
Send only the required fields when fetching a readonly view definition
issue11134
review380081002
diffstat:
customs.py | 27 +++++++++------------------
product.py | 18 +++++-------------
2 files changed, 14 insertions(+), 31 deletions(-)
diffs (147 lines):
diff -r 2011b789107b -r 602bf5696bd5 customs.py
--- a/customs.py Wed Apr 06 23:37:42 2022 +0200
+++ b/customs.py Fri Apr 08 19:07:13 2022 +0200
@@ -41,8 +41,7 @@
start_month = fields.Selection(MONTHS, 'Start Month', sort=False,
states={
'required': Eval('end_month') | Eval('start_day'),
- },
- depends=['end_month', 'start_day'])
+ })
start_day = fields.Integer('Start Day',
domain=['OR',
('start_day', '<=', If(Eval('start_month').in_(
@@ -52,13 +51,11 @@
],
states={
'required': Bool(Eval('start_month')),
- },
- depends=['start_month'])
+ })
end_month = fields.Selection(MONTHS, 'End Month', sort=False,
states={
'required': Eval('start_month') | Eval('end_day'),
- },
- depends=['start_month', 'end_day'])
+ })
end_day = fields.Integer('End Day',
domain=['OR',
('end_day', '<=', If(Eval('end_month').in_(
@@ -68,8 +65,7 @@
],
states={
'required': Bool(Eval('end_month')),
- },
- depends=['end_month'])
+ })
duty_rates = fields.One2Many('customs.duty.rate', 'tariff_code',
'Duty Rates')
@@ -116,15 +112,13 @@
('start_date', '<=', If(Bool(Eval('end_date')),
Eval('end_date', datetime.date.max), datetime.date.max)),
('start_date', '=', None),
- ],
- depends=['end_date'])
+ ])
end_date = fields.Date('End Date',
domain=['OR',
('end_date', '>=', If(Bool(Eval('start_date')),
Eval('start_date', datetime.date.min), datetime.date.min)),
('end_date', '=', None),
- ],
- depends=['start_date'])
+ ])
computation_type = fields.Selection([
('amount', 'Amount'),
('quantity', 'Quantity'),
@@ -133,20 +127,17 @@
states={
'required': Eval('computation_type').in_(['amount', 'quantity']),
'invisible': ~Eval('computation_type').in_(['amount', 'quantity']),
- },
- depends=['computation_type'])
+ })
currency = fields.Many2One('currency.currency', 'Currency',
states={
'required': Eval('computation_type').in_(['amount', 'quantity']),
'invisible': ~Eval('computation_type').in_(['amount', 'quantity']),
- },
- depends=['computation_type'])
+ })
uom = fields.Many2One('product.uom', 'Uom',
states={
'required': Eval('computation_type') == 'quantity',
'invisible': Eval('computation_type') != 'quantity',
- },
- depends=['computation_type'])
+ })
@classmethod
def __setup__(cls):
diff -r 2011b789107b -r 602bf5696bd5 product.py
--- a/product.py Wed Apr 06 23:37:42 2022 +0200
+++ b/product.py Fri Apr 08 19:07:13 2022 +0200
@@ -13,21 +13,18 @@
customs = fields.Boolean('Customs', select=True,
states={
'readonly': Bool(Eval('childs', [0])) | Bool(Eval('parent')),
- },
- depends=['parent'])
+ })
tariff_codes_parent = fields.Boolean("Use Parent's Tariff Codes",
states={
'invisible': ~Eval('customs', False),
},
- depends=['customs'],
help='Use the tariff codes defined on the parent category.')
tariff_codes = fields.One2Many('product-customs.tariff.code',
'product', 'Tariff Codes', order=[('sequence', 'ASC'), ('id', 'ASC')],
states={
'invisible': (Eval('tariff_codes_parent', False)
| ~Eval('customs', False)),
- },
- depends=['tariff_codes_parent', 'customs'])
+ })
@classmethod
def __setup__(cls):
@@ -35,11 +32,9 @@
cls.parent.domain = [
('customs', '=', Eval('customs', False)),
cls.parent.domain or []]
- cls.parent.depends.append('customs')
cls.parent.states['required'] = Or(
cls.parent.states.get('required', False),
Eval('tariff_codes_parent', False))
- cls.parent.depends.append('tariff_codes_parent')
@classmethod
def default_customs(cls):
@@ -100,8 +95,7 @@
],
states={
'required': Eval('tariff_codes_category', False),
- },
- depends=['tariff_codes_category'])
+ })
tariff_codes_category = fields.Boolean("Use Category's Tariff Codes",
help='Use the tariff codes defined on the category.')
tariff_codes = fields.One2Many('product-customs.tariff.code',
@@ -109,14 +103,12 @@
states={
'invisible': ((Eval('type') == 'service')
| Eval('tariff_codes_category', False)),
- },
- depends=['type', 'tariff_codes_category'])
+ })
country_of_origin = fields.Many2One(
'country.country', "Country",
states={
'invisible': Eval('type') == 'service',
- },
- depends=['type'])
+ })
@classmethod
def __register__(cls, module_name):