- Create a product P with a Sales Price of 5000 and a Cost of 3000.
- Create a bill for 10 units @ 3000, post
- Create an invoice for 10 units @ 5000, post
- Create a customer credit note for 5 units
- Open the Product Margin report
The # Purchased is 15 while the # Invoiced in Sale is 10.
The query incorrectly sums the invoice lines based on their type. We
should group customer invoices with customer refunds, and group vendor
bills with vendor refunds. When grouping we should subtract invoices
and refunds.
Note that the `avg_unit_price` is not modified since there is no reason
to refund a product at a different unit price.
opw-2211636
closesodoo/odoo#49349
X-original-commit: d3c6b16e2ad2166b636372b537292e06d4d575c4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>