Better cost price history


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 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.


1 Like

Two things pop into my mind again:

  1. for purchases, the cost price should be reserved for the actual invoiced purchased price…
    any adjustments (like transportation, non-VAT taxes, production costs or other arbitrary values) should be factored in and stored in a different field, such as calculated_cost_price, which can be recomputed ad nauseum based upon business rules/needs.

  2. Why mix logistics moves directly with finance in the first place?

This topic was automatically closed after 13 days. New replies are no longer allowed.