diff --git a/addons/stock/report/report_stock_move.py b/addons/stock/report/report_stock_move.py index 07289a4379a..d728cbf0e29 100644 --- a/addons/stock/report/report_stock_move.py +++ b/addons/stock/report/report_stock_move.py @@ -86,19 +86,19 @@ class report_stock_move(osv.osv): sum(al.in_value - al.out_value) as value FROM (SELECT CASE WHEN sp.type in ('out') THEN - sum(sm.product_qty * pu.factor) + sum(sm.product_qty * pu.factor / pu2.factor) ELSE 0.0 END AS out_qty, CASE WHEN sp.type in ('in') THEN - sum(sm.product_qty * pu.factor) + sum(sm.product_qty * pu.factor / pu2.factor) ELSE 0.0 END AS in_qty, CASE WHEN sp.type in ('out') THEN - sum(sm.product_qty * pu.factor) * pt.standard_price + sum(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price ELSE 0.0 END AS out_value, CASE WHEN sp.type in ('in') THEN - sum(sm.product_qty * pu.factor) * pt.standard_price + sum(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price ELSE 0.0 END AS in_value, min(sm.id) as sm_id, @@ -126,6 +126,7 @@ class report_stock_move(osv.osv): LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id) LEFT JOIN product_product pp ON (sm.product_id=pp.id) LEFT JOIN product_uom pu ON (sm.product_uom=pu.id) + LEFT JOIN product_uom pu2 ON (sm.product_uom=pu2.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN stock_location sl ON (sm.location_id = sl.id) @@ -176,17 +177,16 @@ CREATE OR REPLACE view report_stock_inventory AS ( m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type, m.company_id, m.state as state, m.prodlot_id as prodlot_id, - coalesce(sum(-pt.standard_price * m.product_qty)::decimal, 0.0) as value, - CASE when pt.uom_id = m.product_uom THEN - coalesce(sum(-m.product_qty)::decimal, 0.0) - ELSE - coalesce(sum(-m.product_qty * pu.factor)::decimal, 0.0) END as product_qty + + coalesce(sum(-pt.standard_price * m.product_qty * pu.factor / pu2.factor)::decimal, 0.0) as value, + coalesce(sum(-m.product_qty * pu.factor / pu2.factor)::decimal, 0.0) as product_qty FROM stock_move m LEFT JOIN stock_picking p ON (m.picking_id=p.id) LEFT JOIN product_product pp ON (m.product_id=pp.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN product_uom pu ON (pt.uom_id=pu.id) + LEFT JOIN product_uom pu2 ON (m.product_uom=pu2.id) LEFT JOIN product_uom u ON (m.product_uom=u.id) LEFT JOIN stock_location l ON (m.location_id=l.id) GROUP BY @@ -199,17 +199,15 @@ CREATE OR REPLACE view report_stock_inventory AS ( m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type, m.company_id, m.state as state, m.prodlot_id as prodlot_id, - coalesce(sum(pt.standard_price * m.product_qty )::decimal, 0.0) as value, - CASE when pt.uom_id = m.product_uom THEN - coalesce(sum(m.product_qty)::decimal, 0.0) - ELSE - coalesce(sum(m.product_qty * pu.factor)::decimal, 0.0) END as product_qty + coalesce(sum(pt.standard_price * m.product_qty * pu.factor / pu2.factor)::decimal, 0.0) as value, + coalesce(sum(m.product_qty * pu.factor / pu2.factor)::decimal, 0.0) as product_qty FROM stock_move m LEFT JOIN stock_picking p ON (m.picking_id=p.id) LEFT JOIN product_product pp ON (m.product_id=pp.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN product_uom pu ON (pt.uom_id=pu.id) + LEFT JOIN product_uom pu2 ON (m.product_uom=pu2.id) LEFT JOIN product_uom u ON (m.product_uom=u.id) LEFT JOIN stock_location l ON (m.location_dest_id=l.id) GROUP BY