← Back to team overview

credativ team mailing list archive

[Merge] lp:~credativ/openobject-addons/7.0-rounding-fix-average-price into lp:openobject-addons/7.0

 

Jacob Hicks (credativ) has proposed merging lp:~credativ/openobject-addons/7.0-rounding-fix-average-price into lp:openobject-addons/7.0.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #1183999 in OpenERP Addons: "Difference in accounting and inventory analysis due to rounding"
  https://bugs.launchpad.net/openobject-addons/+bug/1183999

For more details, see:
https://code.launchpad.net/~credativ/openobject-addons/7.0-rounding-fix-average-price/+merge/212205
-- 
https://code.launchpad.net/~credativ/openobject-addons/7.0-rounding-fix-average-price/+merge/212205
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/7.0-rounding-fix-average-price.
=== modified file 'product/product.py'
--- product/product.py	2014-03-05 17:14:56 +0000
+++ product/product.py	2014-03-21 17:20:43 +0000
@@ -692,7 +692,7 @@
     #
     # Could be overrided for variants matrices prices
     #
-    def price_get(self, cr, uid, ids, ptype='list_price', context=None):
+    def price_get(self, cr, uid, ids, ptype='list_price', context=None, round=True):
         if context is None:
             context = {}
 
@@ -717,7 +717,7 @@
                 # Take the price_type currency from the product field
                 # This is right cause a field cannot be in more than one currency
                 res[product.id] = self.pool.get('res.currency').compute(cr, uid, price_type_currency_id,
-                    context['currency_id'], res[product.id],context=context)
+                    context['currency_id'], res[product.id], round=round, context=context)
 
         return res
 

=== modified file 'stock/stock.py'
--- stock/stock.py	2014-03-13 09:50:54 +0000
+++ stock/stock.py	2014-03-21 17:20:43 +0000
@@ -315,7 +315,7 @@
 
                     # Compute based on pricetype
                     # Choose the right filed standard_price to read
-                    amount_unit = product.price_get('standard_price', context=context)[product.id]
+                    amount_unit = product.price_get('standard_price', context=context, round=False)[product.id]
                     price = qty[product_id] * amount_unit
 
                     total_price += price
@@ -1287,7 +1287,7 @@
                             new_std_price = new_price
                         else:
                             # Get the standard price
-                            amount_unit = product.price_get('standard_price', context=context)[product.id]
+                            amount_unit = product.price_get('standard_price', context=context, round=False)[product.id]
                             new_std_price = ((amount_unit * product_avail[product.id])\
                                 + (new_price * qty))/(product_avail[product.id] + qty)
                         # Write the field according to price type field
@@ -2329,7 +2329,7 @@
             if context is None:
                 context = {}
             currency_ctx = dict(context, currency_id = move.company_id.currency_id.id)
-            amount_unit = move.product_id.price_get('standard_price', context=currency_ctx)[move.product_id.id]
+            amount_unit = move.product_id.price_get('standard_price', context=currency_ctx, round=False)[move.product_id.id]
             reference_amount = amount_unit * qty
 
         return reference_amount, reference_currency_id
@@ -2723,7 +2723,7 @@
                         new_std_price = new_price
                     else:
                         # Get the standard price
-                        amount_unit = product.price_get('standard_price', context=context)[product.id]
+                        amount_unit = product.price_get('standard_price', context=context, round=False)[product.id]
                         new_std_price = ((amount_unit * product.qty_available)\
                             + (new_price * qty))/(product.qty_available + qty)