Rifakat (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-577184-rha into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)
Related bugs:
  Bug #1028008 in OpenERP Addons: "6.1 product_margin sale_expected wrong"
  https://bugs.launchpad.net/openobject-addons/+bug/1028008

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577184-rha/+merge/116456

Hello,

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.

Regards,
Rifakat Haradwala
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577184-rha/+merge/116456
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-577184-rha.
=== modified file 'product_margin/product_margin.py'
--- product_margin/product_margin.py	2011-07-01 23:41:24 +0000
+++ product_margin/product_margin.py	2012-07-24 11:55:27 +0000
@@ -56,11 +56,12 @@
                     sum(l.price_unit * l.quantity)/sum(l.quantity) as avg_unit_price,
                     sum(l.quantity) as num_qty,
                     sum(l.quantity * (l.price_subtotal/l.quantity)) as total,
-                    sum(l.quantity * product.list_price) as sale_expected,
-                    sum(l.quantity * product.standard_price) as normal_cost
+                    sum(l.quantity * pt.list_price) as sale_expected,
+                    sum(l.quantity * pt.standard_price) as normal_cost
                 from account_invoice_line l
                 left join account_invoice i on (l.invoice_id = i.id)
-                left join product_template product on (product.id=l.product_id)
+                left join product_product product on (product.id=l.product_id)
+                left join product_template pt on (pt.id=product.product_tmpl_id)
                 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))
                 """
             invoice_types = ('out_invoice', 'in_refund')

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to