[MERGE] forward port of branch 7.0 up to 43db726
This commit is contained in:
commit
21b1203ee0
|
@ -877,6 +877,34 @@ class product_product(osv.osv):
|
||||||
'res_id': product.product_tmpl_id.id,
|
'res_id': product.product_tmpl_id.id,
|
||||||
'target': 'new'}
|
'target': 'new'}
|
||||||
|
|
||||||
|
def _compute_uos_qty(self, cr, uid, ids, uom, qty, uos, context=None):
|
||||||
|
'''
|
||||||
|
Computes product's invoicing quantity in UoS from quantity in UoM.
|
||||||
|
Takes into account the
|
||||||
|
:param uom: Source unit
|
||||||
|
:param qty: Source quantity
|
||||||
|
:param uos: Target UoS unit.
|
||||||
|
'''
|
||||||
|
if not uom or not qty or not uos:
|
||||||
|
return qty
|
||||||
|
uom_obj = self.pool['product.uom']
|
||||||
|
product_id = ids[0] if isinstance(ids, (list, tuple)) else ids
|
||||||
|
product = self.browse(cr, uid, product_id, context=context)
|
||||||
|
if isinstance(uos, (int, long)):
|
||||||
|
uos = uom_obj.browse(cr, uid, uos, context=context)
|
||||||
|
if isinstance(uom, (int, long)):
|
||||||
|
uom = uom_obj.browse(cr, uid, uom, context=context)
|
||||||
|
if product.uos_id: # Product has UoS defined
|
||||||
|
# We cannot convert directly between units even if the units are of the same category
|
||||||
|
# as we need to apply the conversion coefficient which is valid only between quantities
|
||||||
|
# in product's default UoM/UoS
|
||||||
|
qty_default_uom = uom_obj._compute_qty_obj(cr, uid, uom, qty, product.uom_id) # qty in product's default UoM
|
||||||
|
qty_default_uos = qty_default_uom * product.uos_coeff
|
||||||
|
return uom_obj._compute_qty_obj(cr, uid, product.uos_id, qty_default_uos, uos)
|
||||||
|
else:
|
||||||
|
return uom_obj._compute_qty_obj(cr, uid, uom, qty, uos)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class product_packaging(osv.osv):
|
class product_packaging(osv.osv):
|
||||||
_name = "product.packaging"
|
_name = "product.packaging"
|
||||||
|
|
|
@ -1234,7 +1234,7 @@ class stock_picking(osv.osv):
|
||||||
for pick in self.browse(cr, uid, ids, context=context):
|
for pick in self.browse(cr, uid, ids, context=context):
|
||||||
new_picking = None
|
new_picking = None
|
||||||
complete, too_many, too_few = [], [], []
|
complete, too_many, too_few = [], [], []
|
||||||
move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {}
|
move_product_qty, prodlot_ids, product_avail, partial_qty, uos_qty, product_uoms = {}, {}, {}, {}, {}, {}
|
||||||
for move in pick.move_lines:
|
for move in pick.move_lines:
|
||||||
if move.state in ('done', 'cancel'):
|
if move.state in ('done', 'cancel'):
|
||||||
continue
|
continue
|
||||||
|
@ -1248,6 +1248,7 @@ class stock_picking(osv.osv):
|
||||||
prodlot_ids[move.id] = prodlot_id
|
prodlot_ids[move.id] = prodlot_id
|
||||||
product_uoms[move.id] = product_uom
|
product_uoms[move.id] = product_uom
|
||||||
partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
|
partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
|
||||||
|
uos_qty[move.id] = move.product_id._compute_uos_qty(product_uom, product_qty, move.product_uos) if product_qty else 0.0
|
||||||
if move.product_qty == partial_qty[move.id]:
|
if move.product_qty == partial_qty[move.id]:
|
||||||
complete.append(move)
|
complete.append(move)
|
||||||
elif move.product_qty > partial_qty[move.id]:
|
elif move.product_qty > partial_qty[move.id]:
|
||||||
|
@ -1311,7 +1312,7 @@ class stock_picking(osv.osv):
|
||||||
if product_qty != 0:
|
if product_qty != 0:
|
||||||
defaults = {
|
defaults = {
|
||||||
'product_qty' : product_qty,
|
'product_qty' : product_qty,
|
||||||
'product_uos_qty': product_qty, #TODO: put correct uos_qty
|
'product_uos_qty': uos_qty[move.id],
|
||||||
'picking_id' : new_picking,
|
'picking_id' : new_picking,
|
||||||
'state': 'assigned',
|
'state': 'assigned',
|
||||||
'move_dest_id': False,
|
'move_dest_id': False,
|
||||||
|
@ -1325,7 +1326,7 @@ class stock_picking(osv.osv):
|
||||||
move_obj.write(cr, uid, [move.id],
|
move_obj.write(cr, uid, [move.id],
|
||||||
{
|
{
|
||||||
'product_qty': move.product_qty - partial_qty[move.id],
|
'product_qty': move.product_qty - partial_qty[move.id],
|
||||||
'product_uos_qty': move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
|
'product_uos_qty': move.product_uos_qty - uos_qty[move.id],
|
||||||
'prodlot_id': False,
|
'prodlot_id': False,
|
||||||
'tracking_id': False,
|
'tracking_id': False,
|
||||||
})
|
})
|
||||||
|
@ -1341,7 +1342,7 @@ class stock_picking(osv.osv):
|
||||||
product_qty = move_product_qty[move.id]
|
product_qty = move_product_qty[move.id]
|
||||||
defaults = {
|
defaults = {
|
||||||
'product_qty' : product_qty,
|
'product_qty' : product_qty,
|
||||||
'product_uos_qty': product_qty, #TODO: put correct uos_qty
|
'product_uos_qty': uos_qty[move.id],
|
||||||
'product_uom': product_uoms[move.id]
|
'product_uom': product_uoms[move.id]
|
||||||
}
|
}
|
||||||
prodlot_id = prodlot_ids.get(move.id)
|
prodlot_id = prodlot_ids.get(move.id)
|
||||||
|
|
Loading…
Reference in New Issue