Hello everyone,
i created stored computed field that get total value based on lines and some conditions the compute function work well, but when remove the line the computed field value not deleted.
any idea ?
function code:
@api.depends('res_id', 'res_id.consumption_rate', 'res_id.resource_type')
def get_total_values(self):
hour_values = []
ton_values = []
for line in self.res_id:
if line.consumption == 'hour':
hour_values.append(line.consumption_rate)
print(hour_values)
self.total_per_hour_cost = sum(hour_values)
else:
if line.consumption == 'ton':
ton_values.append(line.consumption_rate)
print(ton_values)
self.total_per_ton_cost = sum(ton_values)