← Back to team overview

credativ team mailing list archive

lp:~kinner-vachhani/openobject-addons/fix-1183999-avgpricerounding into lp:~credativ/openobject-addons/6.0-rounding-fixes

 

Kinner Vachhani has proposed merging lp:~kinner-vachhani/openobject-addons/fix-1183999-avgpricerounding into lp:~credativ/openobject-addons/6.0-rounding-fixes.

Requested reviews:
  credativ (credativ)

For more details, see:
https://code.launchpad.net/~kinner-vachhani/openobject-addons/fix-1183999-avgpricerounding/+merge/165754

Avg price rounding bug fix
-- 
https://code.launchpad.net/~kinner-vachhani/openobject-addons/fix-1183999-avgpricerounding/+merge/165754
Your team credativ is requested to review the proposed merge of lp:~kinner-vachhani/openobject-addons/fix-1183999-avgpricerounding into lp:~credativ/openobject-addons/6.0-rounding-fixes.
=== modified file 'product/product.py'
--- product/product.py	2012-03-30 08:53:02 +0000
+++ product/product.py	2013-05-25 17:41:25 +0000
@@ -579,7 +579,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 = {}
 
@@ -604,7 +604,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	2013-05-13 22:25:46 +0000
+++ stock/stock.py	2013-05-25 17:41:25 +0000
@@ -302,7 +302,7 @@
 
                     # Compute based on pricetype
                     # Choose the right filed standard_price to read
-                    amount_unit = product.price_get('standard_price', context)[product.id]
+                    amount_unit = product.price_get('standard_price', context,round=False)[product.id]
                     price = qty[product_id] * amount_unit
 
                     total_price += price
@@ -904,7 +904,7 @@
         if type in ('in_invoice', 'in_refund'):
             # Take the user company and pricetype
             context['currency_id'] = move_line.company_id.currency_id.id
-            amount_unit = move_line.product_id.price_get('standard_price', context)[move_line.product_id.id]
+            amount_unit = move_line.product_id.price_get('standard_price', context,round=False)[move_line.product_id.id]
             return amount_unit
         else:
             return move_line.product_id.list_price
@@ -1218,14 +1218,14 @@
 
                     if qty > 0:
                         new_price = currency_obj.compute(cr, uid, product_currency,
-                                move_currency_id, product_price)
+                                move_currency_id, product_price,round=False)
                         new_price = uom_obj._compute_price(cr, uid, product_uom, new_price,
                                 product.uom_id.id)
                         if product.qty_available <= 0:
                             new_std_price = new_price
                         else:
                             # Get the standard price
-                            amount_unit = product.price_get('standard_price', context)[product.id]
+                            amount_unit = product.price_get('standard_price', 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
@@ -2458,14 +2458,14 @@
                 qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id)
                 if qty > 0:
                     new_price = currency_obj.compute(cr, uid, product_currency,
-                            move_currency_id, product_price)
+                            move_currency_id, product_price,round=False)
                     new_price = uom_obj._compute_price(cr, uid, product_uom, new_price,
                             product.uom_id.id)
                     if product.qty_available <= 0:
                         new_std_price = new_price
                     else:
                         # Get the standard price
-                        amount_unit = product.price_get('standard_price', context)[product.id]
+                        amount_unit = product.price_get('standard_price', context,round=False)[product.id]
                         new_std_price = ((amount_unit * product.qty_available)\
                             + (new_price * qty))/(product.qty_available + qty)
 


Follow ups