Improve performance of average cost price
The do method is written to be sequential because it depends on the status of previous moves. But indeed this constraint is only there is case we process two moves with the same product. So we could save the changes only once we process for the second times the same product.
Also the method _update_product_cost_price does many slow things:
- It writes the cost_price computed, this could be delay later and written with a batch call.
- It instantiates a new product with a specific context, it will be better to process all moves with the same context to get batch computation.
- The product quantity is computed on all storage locations but the most common case is to have one warehouse with all storage inside. So we could request to compute for warehouses and storage outside warehouses. This will allow to benefit from the computation shortcut in Move.compute_quantities.