From ef5301b964a42b71c503fd499d492c7a943da0b0 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Thu, 29 Mar 2018 10:15:06 +0200 Subject: [PATCH] [FIX] l10n_be_hr_payroll: Compute correctly the 'company_car_total_depreciated_cost' The correct solution would be to store the total_depreciated_cost on the fleet vehicle. But this solution is not acceptable on a stable release as it implies to update the module. The only thing we can do here is to add the dependencies on the field 'total_depreciated_costs' to the field 'company_car_total_depreciated_costs'. As the field is not stored, then the field 'company_car_total_depreciated_cost' (which is stored) is not recomputed correctly when modifying the log_contract. This solve the following issue: Modify a recurring costs amount (depreciated) on the fleet vehicle contract, then the final yearly cost on the related hr.contracts are not recomputed correclty, as the field company_car_total_depreciated_cost on the hr.contract is not recomputed on the total_depreciated_cost modification. --- addons/l10n_be_hr_payroll_fleet/models/hr_contract.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/l10n_be_hr_payroll_fleet/models/hr_contract.py b/addons/l10n_be_hr_payroll_fleet/models/hr_contract.py index 06edfb703ba..012cc24ce56 100644 --- a/addons/l10n_be_hr_payroll_fleet/models/hr_contract.py +++ b/addons/l10n_be_hr_payroll_fleet/models/hr_contract.py @@ -20,7 +20,9 @@ class HrContract(models.Model): max_unused_cars = fields.Integer(compute='_compute_max_unused_cars') @api.depends('car_id', 'new_car', 'new_car_model_id', 'car_id.total_depreciated_cost', - 'car_id.atn', 'new_car_model_id.default_atn', 'new_car_model_id.default_total_depreciated_cost') + 'car_id.atn', 'new_car_model_id.default_atn', 'new_car_model_id.default_total_depreciated_cost', + 'car_id.co2_fee', 'car_id.log_contracts', 'car_id.log_contracts.state', # YTI TODO: Store total_depreciated_costs on + 'car_id.log_contracts.recurring_cost_amount_depreciated') # the fleet vehicle to avoid these dependencies def _compute_car_atn_and_costs(self): for contract in self: if not contract.new_car and contract.car_id: