Purchase/Sale history of a product

Following Need to find purchases by products

We also think it could be useful to know purchase/sale history of a product (to which suppliers a product was bought, when was last purchase, what was the purchase/sale price, the quantity, …).
Reporting don’t give all information at once.

So, wondering if a relate from product on purchase_lines/sale_lines (with some function fields from header for details) could help the user to find such information quickly? (and easy to implement)
Maybe this could be done with a new model based on a query for more efficiency ?

We did such add-on as a customization, but we think many users did the same, so why not adding this in sale/purchase modules?

Indeed it makes sense but it will be great to prevent to create lines from this view because we do not really have protection against adding lines to confirmed orders (or we should add such constraint).
Also I think we should try to reduce the number of relate on the product probably by using links for those that works only on 1 product. And also improve the discoverability by adding some relate also as links.

What details?

I do not see why we would need a table query model?

As relate is on lines, some fields are missing for having whole information at once: supplier/customer, sale_date, currency, number, reference, …

Don’t know. But to add missing details (see my previous answer) on the purchase_line/sale_line model, we add some function fields to get info from the header (like for state field). So maybe using a lot of function fields on a model could slow for other use?

Indeed it will be annoying to have to add many Function field on the line, mainly because it may prevent customization that would want to override the order value at the line level.
So probably having a dedicated model for that is not a bad idea and it will solve the creation issue.

I like the idea of a dedicated model.

We have also added the lines view as customization to allow answering such questions:

  • Which was the last products that I sold to a customer?

In such case we just have a dedicated view for the lines where the user can filter by customer, sale date or product. To allow to see the details.

For reporting, we can have a new level which shows the details from where the grouped amounts come for.

Just sharing some thougths