changeset b57fef4e6a1d in modules/account_asset:default details: https://hg.tryton.org/modules/account_asset?cmd=changeset&node=b57fef4e6a1d description: Send only the required fields when fetching a readonly view definition
issue11134 review380081002 diffstat: account.py | 6 ++---- asset.py | 46 ++++++++++++++-------------------------------- invoice.py | 5 +---- product.py | 15 +++++---------- 4 files changed, 22 insertions(+), 50 deletions(-) diffs (257 lines): diff -r b23d11d61581 -r b57fef4e6a1d account.py --- a/account.py Wed Apr 06 23:37:41 2022 +0200 +++ b/account.py Fri Apr 08 19:07:12 2022 +0200 @@ -94,8 +94,7 @@ ('company', 'in', [Eval('company', -1), None]), ('sequence_type', '=', Id('account_asset', 'sequence_type_asset')), - ], - depends=['company']) + ]) @classmethod def __register__(cls, module_name): @@ -164,8 +163,7 @@ states={ 'invisible': ((Eval('statement') != 'balance') | ~Eval('assets', True)), - }, - depends=['statement', 'assets']) + }) if not template: for fname in dir(Mixin): field = getattr(Mixin, fname) diff -r b23d11d61581 -r b57fef4e6a1d asset.py --- a/asset.py Wed Apr 06 23:37:41 2022 +0200 +++ b/asset.py Fri Apr 08 19:07:12 2022 +0200 @@ -58,7 +58,7 @@ context={ 'company': Eval('company', None), }, - depends=['state', 'company'], + depends={'company'}, domain=[ ('type', '=', 'assets'), ('depreciable', '=', True), @@ -78,8 +78,7 @@ ], states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), - }, - depends=['product', 'state', 'company']) + }) customer_invoice_line = fields.Function(fields.Many2One( 'account.invoice.line', 'Customer Invoice Line'), 'get_customer_invoice_line') @@ -87,14 +86,12 @@ states={ 'readonly': Eval('state') != 'draft', }, - depends=['state'], domain=[('type', '=', 'asset')], required=True) company = fields.Many2One('company.company', 'Company', states={ 'readonly': Eval('state') != 'draft', }, - depends=['state'], required=True) currency = fields.Function(fields.Many2One('currency.currency', 'Currency'), 'on_change_with_currency') @@ -104,20 +101,17 @@ 'readonly': (Bool(Eval('supplier_invoice_line', 1)) | Eval('lines', [0]) | (Eval('state') != 'draft')), - }, - depends=['state']) + }) unit = fields.Many2One('product.uom', 'Unit', states={ 'readonly': (Bool(Eval('product')) | (Eval('state') != 'draft')), - }, - depends=['state']) + }) value = Monetary( "Value", currency='currency', digits='currency', states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), }, - depends=['state'], required=True, help="The value of the asset when purchased.") depreciated_amount = Monetary( @@ -128,7 +122,6 @@ states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), }, - depends=['value', 'state'], required=True, help="The amount already depreciated at the start date.") depreciating_value = fields.Function(Monetary( @@ -143,36 +136,31 @@ ], states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), - }, - depends=['depreciating_value', 'state']) + }) purchase_date = fields.Date('Purchase Date', states={ 'readonly': (Bool(Eval('supplier_invoice_line', 1)) | Eval('lines', [0]) | (Eval('state') != 'draft')), }, - required=True, - depends=['state']) + required=True) start_date = fields.Date('Start Date', states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), }, required=True, - domain=[('start_date', '<=', Eval('end_date', None))], - depends=['state', 'end_date']) + domain=[('start_date', '<=', Eval('end_date', None))]) end_date = fields.Date('End Date', states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), }, required=True, - domain=[('end_date', '>=', Eval('start_date', None))], - depends=['state', 'start_date']) + domain=[('end_date', '>=', Eval('start_date', None))]) depreciation_method = fields.Selection([ ('linear', 'Linear'), ], 'Depreciation Method', states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), }, - required=True, - depends=['state']) + required=True) frequency = fields.Selection([ ('monthly', 'Monthly'), ('yearly', 'Yearly'), @@ -180,8 +168,7 @@ required=True, states={ 'readonly': (Eval('lines', [0]) | (Eval('state') != 'draft')), - }, - depends=['state']) + }) state = fields.Selection([ ('draft', 'Draft'), ('running', 'Running'), @@ -192,8 +179,7 @@ move = fields.Many2One('account.move', 'Account Move', readonly=True, domain=[ ('company', '=', Eval('company', -1)), - ], - depends=['company']) + ]) update_moves = fields.Many2Many('account.asset-update-account.move', 'asset', 'move', 'Update Moves', readonly=True, domain=[ @@ -201,8 +187,7 @@ ], states={ 'invisible': ~Eval('update_moves'), - }, - depends=['company']) + }) comment = fields.Text('Comment') revisions = fields.One2Many( 'account.asset.revision', 'asset', "Revisions", readonly=True) @@ -806,7 +791,6 @@ ('date', '>=', Eval('latest_move_date')), ('date', '<=', Eval('next_depreciation_date')), ], - depends=['latest_move_date', 'next_depreciation_date'], help=('The date must be between the last update/depreciation date ' 'and the next depreciation date.')) latest_move_date = fields.Date('Latest Move Date', readonly=True) @@ -1151,11 +1135,9 @@ __name__ = 'account.asset.print_depreciation_table.start' start_date = fields.Date('Start Date', required=True, - domain=[('start_date', '<', Eval('end_date'))], - depends=['end_date']) + domain=[('start_date', '<', Eval('end_date'))]) end_date = fields.Date('End Date', required=True, - domain=[('end_date', '>', Eval('start_date'))], - depends=['start_date']) + domain=[('end_date', '>', Eval('start_date'))]) @staticmethod def default_start_date(): diff -r b23d11d61581 -r b57fef4e6a1d invoice.py --- a/invoice.py Wed Apr 06 23:37:41 2022 +0200 +++ b/invoice.py Fri Apr 08 19:07:12 2022 +0200 @@ -16,10 +16,7 @@ 'invisible': (~Eval('is_assets_depreciable', False) | (Eval('invoice_type') != 'out')), 'readonly': Eval('invoice_state') != 'draft', - }, - depends=[ - 'product', 'is_assets_depreciable', - 'invoice_state', 'invoice_type']) + }) is_assets_depreciable = fields.Function(fields.Boolean( 'Is Assets depreciable'), 'on_change_with_is_assets_depreciable') diff -r b23d11d61581 -r b57fef4e6a1d product.py --- a/product.py Wed Apr 06 23:37:41 2022 +0200 +++ b/product.py Fri Apr 08 19:07:12 2022 +0200 @@ -19,8 +19,7 @@ 'invisible': (~Eval('context', {}).get('company') | Eval('account_parent') | ~Eval('accounting', False)), - }, - depends=['account_parent', 'accounting'])) + })) account_asset = fields.MultiValue(fields.Many2One('account.account', 'Account Asset', domain=[ @@ -31,8 +30,7 @@ 'invisible': (~Eval('context', {}).get('company') | Eval('account_parent') | ~Eval('accounting', False)), - }, - depends=['account_parent', 'accounting'])) + })) @classmethod def multivalue_model(cls, field): @@ -69,15 +67,13 @@ domain=[ ('type.fixed_asset', '=', True), ('company', '=', Eval('company', -1)), - ], - depends=['company']) + ]) account_asset = fields.Many2One( 'account.account', "Account Asset", domain=[ ('type.fixed_asset', '=', True), ('company', '=', Eval('company', -1)), - ], - depends=['company']) + ]) @classmethod def __register__(cls, module_name): @@ -105,14 +101,13 @@ __name__ = 'product.template' depreciable = fields.Boolean('Depreciable', states={ 'invisible': Eval('type', '') != 'assets', - }, depends=['type']) + }) depreciation_duration = fields.Integer( "Depreciation Duration", states={ 'invisible': (~Eval('depreciable') | (Eval('type', '') != 'assets')), }, - depends=['depreciable', 'type'], help='In months') @property