[FIX] stock: onchange_quantity and onchange_uos_quantity use rounding
It is necessary to round the quantities with the appropriate precision. Indeed,
since onchange_quantity and onchange_uos_quantity trigger each other indirectly,
it is quite easy to fall in an infinite loop if the uom and uos precisions are
different.
Follows commit 6e346f0adb
opw-643651
This commit is contained in:
@@ -29,7 +29,7 @@ from openerp.osv import fields, osv, orm
|
|||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp import netsvc
|
from openerp import netsvc
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp.tools import float_compare, DEFAULT_SERVER_DATETIME_FORMAT
|
from openerp.tools import float_compare, float_round, DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
import openerp.addons.decimal_precision as dp
|
import openerp.addons.decimal_precision as dp
|
||||||
import logging
|
import logging
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@@ -1873,7 +1873,8 @@ class stock_move(osv.osv):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if product_uos and product_uom and (product_uom != product_uos):
|
if product_uos and product_uom and (product_uom != product_uos):
|
||||||
result['product_uos_qty'] = product_qty * uos_coeff['uos_coeff']
|
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Product UoS')
|
||||||
|
result['product_uos_qty'] = float_round(product_qty * uos_coeff['uos_coeff'], precision_digits=precision)
|
||||||
else:
|
else:
|
||||||
result['product_uos_qty'] = product_qty
|
result['product_uos_qty'] = product_qty
|
||||||
|
|
||||||
@@ -1903,7 +1904,8 @@ class stock_move(osv.osv):
|
|||||||
# The clients should call onchange_quantity too anyway
|
# The clients should call onchange_quantity too anyway
|
||||||
|
|
||||||
if product_uos and product_uom and (product_uom != product_uos):
|
if product_uos and product_uom and (product_uom != product_uos):
|
||||||
result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff']
|
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Unit of Measure')
|
||||||
|
result['product_qty'] = float_round(product_uos_qty / uos_coeff['uos_coeff'], precision_digits=precision)
|
||||||
else:
|
else:
|
||||||
result['product_qty'] = product_uos_qty
|
result['product_qty'] = product_uos_qty
|
||||||
return {'value': result}
|
return {'value': result}
|
||||||
|
|||||||
Reference in New Issue
Block a user