Hi,
I want to get the total cost of all products that belongs to the category "MO"
Everything works fine except the _total_mo function.
See my BOM here : https://imgur.com/a/9VzutCU
Here is my code :
total_mo = fields.Float(compute='_total_mo', string='Coût total MO')
@api.multi
@api.depends('bom_line_ids')
def _total_mo(self,):
for bom_obj in self:
total_bom_cost = 0
for bom_line in bom_obj.bom_line_ids:
if bom_line.product_id.product_tmpl_id.categ_id.name == 'MO':
total_bom_cost += bom_line.total_cost_price
bom_obj.total_bom_cost = total_bom_cost
Any idea ? Thanks in advance