[FIX]:lp-504353 conversion of UOM with different categories
bzr revid: ksa@tinyerp.co.in-20101111124124-w9ua73s06mxp0ld3
This commit is contained in:
parent
3824f673d7
commit
3a696defc8
|
@ -106,8 +106,13 @@ class product_uom(osv.osv):
|
|||
from_unit, to_unit = uoms[-1], uoms[0]
|
||||
return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit)
|
||||
|
||||
def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context={}):
|
||||
def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if from_unit.category_id.id <> to_unit.category_id.id:
|
||||
if context.get('raise-exception', True):
|
||||
raise osv.except_osv(_('Error !'), _('Conversion from Product UoM m to Default UoM PCE is not possible as they both belong to different Category!.'))
|
||||
else:
|
||||
return qty
|
||||
amount = qty / from_unit.factor
|
||||
if to_unit:
|
||||
|
|
|
@ -282,13 +282,14 @@ class product_product(osv.osv):
|
|||
uoms = uom_obj.browse(cr, uid, list(set(uoms)), context=context)
|
||||
for o in uoms:
|
||||
uoms_o[o.id] = o
|
||||
ctx = {'raise-exception': False} #TOCHECK: before change uom of product, stock move line are in old uom.
|
||||
for amount, prod_id, prod_uom in results:
|
||||
amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount,
|
||||
uoms_o[context.get('uom', False) or product2uom[prod_id]])
|
||||
uoms_o[context.get('uom', False) or product2uom[prod_id]], context=ctx)
|
||||
res[prod_id] += amount
|
||||
for amount, prod_id, prod_uom in results2:
|
||||
amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount,
|
||||
uoms_o[context.get('uom', False) or product2uom[prod_id]])
|
||||
uoms_o[context.get('uom', False) or product2uom[prod_id]], context=ctx)
|
||||
res[prod_id] -= amount
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue