Rational
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).
Proposal
- Add stock dependency to
product_cost_history
module. - Change the query in
product_cost_history
to be based on stock moves - Change getter of
cost_price
MultiValue field to read from history query the cost when_datetime
is in the context.