Merge lp:~openerp-dev/openobject-addons/6.1-opw-577184-rha into lp:openobject-addons/6.1

Proposed by Rifakat Husen (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-577184-rha
Merge into: lp:openobject-addons/6.1
Diff against target: 19 lines (+4/-3)
1 file modified
product_margin/ (+4/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-577184-rha
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email:

Description of the change


Fields 'Expected Sale' and 'Normal Cost' displays wrong amount when product id and product_tmpl_id
are different.

Normally product id and product_tmpl_id are same but that may be different.

Steps to reproduce:
1. Install module product_margin
2. Create any customer/supplier invoice and check Expected Sale/Normal Cost field
   from menu Sales> Products> Product Margins

Please review this fix.

Rifakat Haradwala

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :


This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Naresh Soni

Unmerged revisions

6914. By Peter Langenberg

[fix] product_margin: fix computation of expected_margin and normal_cost in query, it shows wrong value while product id and product_tmpl_id are different

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product_margin/'
2--- product_margin/ 2011-07-01 23:41:24 +0000
3+++ product_margin/ 2012-07-24 11:55:27 +0000
4@@ -56,11 +56,12 @@
5 sum(l.price_unit * l.quantity)/sum(l.quantity) as avg_unit_price,
6 sum(l.quantity) as num_qty,
7 sum(l.quantity * (l.price_subtotal/l.quantity)) as total,
8- sum(l.quantity * product.list_price) as sale_expected,
9- sum(l.quantity * product.standard_price) as normal_cost
10+ sum(l.quantity * pt.list_price) as sale_expected,
11+ sum(l.quantity * pt.standard_price) as normal_cost
12 from account_invoice_line l
13 left join account_invoice i on (l.invoice_id =
14- left join product_template product on (
15+ left join product_product product on (
16+ left join product_template pt on (
17 where l.product_id = %s and i.state in %s and i.type IN %s and (i.date_invoice IS NULL or (i.date_invoice>=%s and i.date_invoice<=%s))
18 """
19 invoice_types = ('out_invoice', 'in_refund')