I want to update a field named cost_price_set in model sale.order.line with 40 as a sample. I have try this but the value still does not updated in the field.
@api.depends('line_ids.sale_order_id','line_ids.product_id')
def hpp_update(self):
for record in self:
invoice_pool = self.env['sale.order.line']
for invoice in invoice_pool.search([('order_id', '=', record.line_ids.sale_order_id.id),('product_id', '=', record.line_ids.product_id.id)]):
invoice.write({'cost_price_set': '40'})
return True
Please help. Thank you
I found that nothing wrong with the script. The problem was that the field that I want to inset is compute field. When the field is non compute, it works.