Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-937669-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #937669 in OpenERP Addons: "[6.1] Another average cost error - this time 
in _get_reference_values function in Stock"
  https://bugs.launchpad.net/openobject-addons/+bug/937669

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-937669-mma/+merge/96991

Hello,
   
    stock: passed move product qty in reference amount

Thanks.
mma
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-937669-mma/+merge/96991
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-937669-mma.
=== modified file 'stock/stock.py'
--- stock/stock.py	2012-02-28 14:08:16 +0000
+++ stock/stock.py	2012-03-12 10:32:21 +0000
@@ -2149,13 +2149,10 @@
         # by default the reference currency is that of the move's company
         reference_currency_id = move.company_id.currency_id.id
 
-        default_uom = move.product_id.uom_id.id
-        qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
-
         # if product is set to average price and a specific value was entered in the picking wizard,
         # we use it
         if move.product_id.cost_method == 'average' and move.price_unit:
-            reference_amount = qty * move.price_unit
+            reference_amount = move.product_qty * move.price_unit
             reference_currency_id = move.price_currency_id.id or reference_currency_id
 
         # Otherwise we default to the company's valuation price type, considering that the values of the
@@ -2163,8 +2160,10 @@
         else:
             if context is None:
                 context = {}
-            currency_ctx = dict(context, currency_id = move.company_id.currency_id.id)
+            currency_ctx = dict(context, currency_id = reference_currency_id)
             amount_unit = move.product_id.price_get('standard_price', context=currency_ctx)[move.product_id.id]
+            default_uom = move.product_id.uom_id.id
+            qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
             reference_amount = amount_unit * qty or 1.0
 
         return reference_amount, reference_currency_id

_______________________________________________
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