[IMP] Change _compute_qty to0 _compute_qty_obj in order to pass browse records immediately instead
bzr revid: jco@openerp.com-20140228173241-qfenlx2hb8h1k40j
This commit is contained in:
parent
753c125024
commit
d39056faec
|
@ -159,6 +159,7 @@ class product_uom(osv.osv):
|
|||
('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!')
|
||||
]
|
||||
|
||||
|
||||
def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, round=True):
|
||||
if not from_uom_id or not qty or not to_uom_id:
|
||||
return qty
|
||||
|
|
|
@ -1276,7 +1276,7 @@ class stock_move(osv.osv):
|
|||
uom_obj = self.pool.get('product.uom')
|
||||
res = {}
|
||||
for m in self.browse(cr, uid, ids, context=context):
|
||||
res[m.id] = uom_obj._compute_qty_obj(cr, uid, m.product_uom, m.product_uom_qty, m.product_id.uom_id, round=False)
|
||||
res[m.id] = uom_obj._compute_qty_obj(cr, uid, m.product_uom, m.product_uom_qty, m.product_id.uom_id, round=False, context=context)
|
||||
return res
|
||||
|
||||
def _get_remaining_qty(self, cr, uid, ids, field_name, args, context=None):
|
||||
|
@ -1287,7 +1287,7 @@ class stock_move(osv.osv):
|
|||
for record in move.linked_move_operation_ids:
|
||||
qty -= record.qty
|
||||
#converting the remaining quantity in the move UoM
|
||||
res[move.id] = uom_obj._compute_qty(cr, uid, move.product_id.uom_id.id, qty, move.product_uom.id)
|
||||
res[move.id] = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, qty, move.product_uom, round=False, context=context)
|
||||
return res
|
||||
|
||||
def _get_lot_ids(self, cr, uid, ids, field_name, args, context=None):
|
||||
|
@ -1323,7 +1323,7 @@ class stock_move(osv.osv):
|
|||
res[move.id] = '' # 'not applicable' or 'n/a' could work too
|
||||
continue
|
||||
total_available = min(move.product_qty, move.reserved_availability + move.availability)
|
||||
total_available = uom_obj._compute_qty(cr, uid, move.product_id.uom_id.id, total_available, move.product_uom.id)
|
||||
total_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, total_available, move.product_uom, context=context)
|
||||
info = str(total_available)
|
||||
#look in the settings if we need to display the UoM name or not
|
||||
config_ids = settings_obj.search(cr, uid, [], limit=1, order='id DESC', context=context)
|
||||
|
@ -1334,7 +1334,7 @@ class stock_move(osv.osv):
|
|||
if move.reserved_availability:
|
||||
if move.reserved_availability != total_available:
|
||||
#some of the available quantity is assigned and some are available but not reserved
|
||||
reserved_available = uom_obj._compute_qty(cr, uid, move.product_id.uom_id.id, move.reserved_availability, move.product_uom.id)
|
||||
reserved_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, move.reserved_availability, move.product_uom, context=context)
|
||||
info += _(' (%s reserved)') % str(reserved_available)
|
||||
else:
|
||||
#all available quantity is assigned
|
||||
|
@ -2164,7 +2164,7 @@ class stock_move(osv.osv):
|
|||
uom_obj = self.pool.get('product.uom')
|
||||
context = context or {}
|
||||
|
||||
uom_qty = uom_obj._compute_qty(cr, uid, move.product_id.uom_id.id, qty, move.product_uom.id)
|
||||
uom_qty = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, qty, move.product_uom)
|
||||
uos_qty = uom_qty * move.product_uos_qty / move.product_uom_qty
|
||||
|
||||
defaults = {
|
||||
|
@ -3463,12 +3463,12 @@ class stock_pack_operation(osv.osv):
|
|||
else:
|
||||
qty = ops.product_qty
|
||||
if ops.product_uom_id:
|
||||
qty = uom_obj._compute_qty(cr, uid, ops.product_uom_id.id, ops.product_qty, ops.product_id.uom_id.id)
|
||||
qty = uom_obj._compute_qty_obj(cr, uid, ops.product_uom_id, ops.product_qty, ops.product_id.uom_id, context=context)
|
||||
for record in ops.linked_move_operation_ids:
|
||||
qty -= record.qty
|
||||
#converting the remaining quantity in the pack operation UoM
|
||||
if ops.product_uom_id:
|
||||
qty = uom_obj._compute_qty(cr, uid, ops.product_id.uom_id.id, qty, ops.product_uom_id.id)
|
||||
qty = uom_obj._compute_qty_obj(cr, uid, ops.product_id.uom_id, qty, ops.product_uom_id, context=context)
|
||||
res[ops.id] = qty
|
||||
return res
|
||||
|
||||
|
@ -3559,7 +3559,7 @@ class stock_pack_operation(osv.osv):
|
|||
before = time.time()
|
||||
link_obj.create(cr, uid, {'move_id': quant.reservation_id.id, 'operation_id': ops.id, 'qty': quant.qty}, context=context)
|
||||
else:
|
||||
qty = uom_obj._compute_qty(cr, uid, ops.product_uom_id.id, ops.product_qty, ops.product_id.uom_id.id)
|
||||
qty = uom_obj._compute_qty_obj(cr, uid, ops.product_uom_id, ops.product_qty, ops.product_id.uom_id, context=context)
|
||||
#Check moves with same product
|
||||
for move in [x for x in ops.picking_id.move_lines if ops.product_id.id == x.product_id.id]:
|
||||
for quant in move.reserved_quant_ids:
|
||||
|
@ -3611,7 +3611,7 @@ class stock_pack_operation(osv.osv):
|
|||
op.refresh()
|
||||
if op.product_id:
|
||||
#TODO: Remaining qty: UoM conversions are done twice
|
||||
normalized_qty = uom_obj._compute_qty(cr, uid, op.product_uom_id.id, op.remaining_qty, op.product_id.uom_id.id)
|
||||
normalized_qty = uom_obj._compute_qty_obj(cr, uid, op.product_uom_id, op.remaining_qty, op.product_id.uom_id)
|
||||
if normalized_qty > 0:
|
||||
quants_reserve_ok = False
|
||||
_create_link_for_product(op.product_id.id, normalized_qty)
|
||||
|
|
Loading…
Reference in New Issue