[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.
This commit is contained in:
Yannick Tivisse
2018-03-29 10:24:15 +02:00
parent 35d507bc6a
commit ef5301b964
@@ -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: