The historization of the cost price is currently done using the
_history feature. The problem is that it does not work well when the cost price is recomputed because the Tryton history is immutable.
Indeed the cost price changes only when there is an incoming move done and we store the cost price on each move done. So this means that we already have the history of the cost price stored on the moves. And we can display it on a timeline (per day) if we group all incoming moves per date and cost price (usually the cost price will be the same for a day thanks to the cron re-computation).
- Add stock dependency to
- Change the query in
product_cost_historyto be based on stock moves
- Change getter of
cost_priceMultiValue field to read from history query the cost when
_datetimeis in the context.