← Back to team overview

credativ team mailing list archive

lp:~credativ/openobject-addons/6.1-stockmove-unitprice-precision into lp:~credativ/openobject-addons/6.1

 

Kinner Vachhani has proposed merging lp:~credativ/openobject-addons/6.1-stockmove-unitprice-precision into lp:~credativ/openobject-addons/6.1.

Requested reviews:
  credativ (credativ)
Related bugs:
  Bug #1191041 in OpenERP Addons: "stock accounting: price_unit is not precise enough"
  https://bugs.launchpad.net/openobject-addons/+bug/1191041

For more details, see:
https://code.launchpad.net/~credativ/openobject-addons/6.1-stockmove-unitprice-precision/+merge/170169

Observed behaviour: Stock accounting entry is inaccurate

Steps to reproduce:

Create a product and configure it for stock accounting and average price costing
* Configure decimal precision and set purchase price to 6 decimal places
* Create an incoming stock move of quantity 100
* Book the stock in at a price including more than 2 decimal places. e.g. 1.123456 (Note that this needs the change to the wizard to show more than 2 decimal places)

Expected behaviour: The stock accounting entry would be for 100*1.123456, rounded to 2 decimal places: 112.34

Actual behaviour: the price is rounded before multiplying: 100*1.12 = 112, ie a difference of £0.34

The problem is due to price_unit in stock move. It has a precision of Account, but this is only 2 decimal places. So we can use the Purchase Price precision instead
-- 
https://code.launchpad.net/~credativ/openobject-addons/6.1-stockmove-unitprice-precision/+merge/170169
Your team credativ is requested to review the proposed merge of lp:~credativ/openobject-addons/6.1-stockmove-unitprice-precision into lp:~credativ/openobject-addons/6.1.
=== modified file 'account/wizard/account_chart.py'
--- account/wizard/account_chart.py	2011-10-27 21:11:24 +0000
+++ account/wizard/account_chart.py	2013-06-18 19:01:26 +0000
@@ -51,7 +51,7 @@
                                FROM account_period p
                                LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                                WHERE f.id = %s
-                               ORDER BY p.date_start ASC
+                               ORDER BY p.date_start ASC, p.special DESC
                                LIMIT 1) AS period_start
                 UNION ALL
                 SELECT * FROM (SELECT p.id
@@ -59,7 +59,7 @@
                                LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                                WHERE f.id = %s
                                AND p.date_start < NOW()
-                               ORDER BY p.date_stop DESC
+                               ORDER BY p.date_stop DESC, p.special DESC
                                LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
             periods =  [i[0] for i in cr.fetchall()]
             if periods and len(periods) > 1:

=== modified file 'stock/stock.py'
--- stock/stock.py	2013-04-05 07:28:21 +0000
+++ stock/stock.py	2013-06-18 19:01:26 +0000
@@ -1604,7 +1604,7 @@
         'state': fields.selection([('draft', 'New'), ('waiting', 'Waiting Another Move'), ('confirmed', 'Waiting Availability'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
               help='When the stock move is created it is in the \'Draft\' state.\n After that, it is set to \'Not Available\' state if the scheduler did not find the products.\n When products are reserved it is set to \'Available\'.\n When the picking is done the state is \'Done\'.\
               \nThe state is \'Waiting\' if the move is waiting for another one.'),
-        'price_unit': fields.float('Unit Price', digits_compute= dp.get_precision('Account'), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
+        'price_unit': fields.float('Unit Price', digits_compute= dp.get_precision('Purchase Price'), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
         'price_currency_id': fields.many2one('res.currency', 'Currency for average price', help="Technical field used to record the currency chosen by the user during a picking confirmation (when average price costing method is used)"),
         'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
         'partner_id': fields.related('picking_id','address_id','partner_id',type='many2one', relation="res.partner", string="Partner", store=True, select=True),