Yes, the above is correct as we are using purchase_landed_costs and confirm the following with camptocamp module:
=> I understand. The point is, this is very difficult and cost a lot to achieve due to the structure of OpenERP (or odoo).
Currently, we solved that this way: * AVG price is computed with the PO landed costs when receiving the goods (picking ->done)
* The margin in the SO line are computed using the current value (means the actual AVG price before ordering new goods to the supplier)
* IF THE CUSTOMER INVOICE is generated AFTER deliveries, then you can have the proper margin computed in the invoice line using the product_historical_margin module). Because here, the AVG cost taken is the one after validating the incoming shipment from the supplier. So:
a) SO confirmed by customer with margin = current value
b) PO ordred to supplier
c) Goods received and AVG price updated
d) Customer invoice generated with proper margin
So my advice is here to compute commission based on invoice line instead of sales order lines.
Our next module is to create an a workflow "Waiting Landed Costs" so we will not receive the product until we have all Landed costs on the product view and sales order line. With using margin-analysis modules from camptocamp we can generate the true margin for reporting