How is recompute cost price done

And if the method to compute the cost_price is the average with a goods product. And I use the recompute cost_price wizard from the variant, which are the operations that are done to compute the average cost_price?.
Because I debugged in the function recompute_cost_price_average(). And it seems like it takes the moves of the product and iterate between them. But at the end doesn’t make any operation to get an average.

At the beginning of the loop it write current cost price when date changes and write a last one at the end of the loop.
Then it returns the last cost price that will be written on the product.

Okayy, and for example, when a production is finished, the cost_price of the product that is fabricated is updated too. And I think that the way that compute average cost_price is in the function set_cost(), if I’m not wrong.
In both ways a record is inserted in the table product_cost_price, that cost_price multivalue field get his value in that table (product_cost_price).
But I don’t see the moment that this record is inserted, and the operations that are done to compute the cost_price when is triggered when finishing a production.

Yes, in live the cost price is not computed from Product.recompute_cost_price* methods but by Move._compute_product_cost_price.

And Production.set_cost is just filling the unit price of the outputs.

It is in

Thanks a lot!. Now it’s clear.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.