This question has been flagged

Hi there

Using Odoo 13 CE, I built a custom module(x.cost) having several computed fields,

I am trying to update value from a computed field(u_cost) into product.template(cost_price) field

Here is the code

u_cost = fields.Float(string='my cost', compute='_ucost_calc', store=True)

@api.depends('total_cost', 'quantity')
def _ucost_calc(self):
for a in self:
        a.u_cost = a.total_cost / a.quantity

I'm trying to update this 'u_cost' value into the Product.template 'cost_price' field.

have tried cr.execute, self.env and most of the methods, but unable to get the u_cost value into the product.template cost_price field...

Being new to python coding, would appreciate exact code for this

Thank you in advance

Avatar
Discard

If you are new to odoo and python development, have a look at this:

https://goo.gl/8HgnCF