summaryrefslogtreecommitdiff
path: root/addons/product_margin/models
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-03-02 11:25:48 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-03-03 12:18:51 +0000
commit071b00f6a1cea4be52258499154222f095deb887 (patch)
tree5e082dcda3d1a909fc78abcc0b1cc53484da898c /addons/product_margin/models
parentcce4730e59f6034b3472f5bd4bfd0ba906565cbe (diff)
[FIX] product_margin: exclude accounting line from calculation
Install account_accountant,stock,purchase,sale_management Activate 'Margin Analysis' in Accounting settings Create a new product (on the category set FIFO and Automated Inventory Valuation). Set $100 for the price and $60 for the cost, update 2 quantity on hand. Receive 1 more product via PO ($70 as the cost), and deliver 1 via SO. With 2 quantity left (inventory value is $135 for 1 $60 and 1 $75) open Accounting>Reporting>Product Margins The Avg. Sale Unit Price and #Invoiced in Sale are incorrect, we only sold 1 item so far, but the report display 3. This occur because accounting lines are kept into the calculation of the sale line. Using 'exclude_from_invoice_tab' to filter out such lines fix the issue. opw-2196625 closes odoo/odoo#46741 X-original-commit: 5f28d1865aa6b4e204e052bf43ecfbfe7d45252b Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/product_margin/models')
-rw-r--r--addons/product_margin/models/product_product.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/product_margin/models/product_product.py b/addons/product_margin/models/product_product.py
index c43ff4f925b..a6e16b5a93e 100644
--- a/addons/product_margin/models/product_product.py
+++ b/addons/product_margin/models/product_product.py
@@ -129,6 +129,7 @@ class ProductProduct(models.Model):
AND i.invoice_date BETWEEN %s AND %s
AND i.company_id = %s
AND l.display_type IS NULL
+ AND l.exclude_from_invoice_tab = false
""".format(self.env['res.currency']._select_companies_rates())
invoice_types = ('out_invoice', 'in_refund')
self.env.cr.execute(sqlstr, (val.id, states, payment_states, invoice_types, date_from, date_to, company_id))