[MERGE] lp: 891596
bzr revid: qdp-launchpad@openerp.com-20111121171404-tnluzcl5p8cc5fwm
This commit is contained in:
commit
e255e0a4c4
|
@ -757,6 +757,10 @@ class sale_order(osv.osv):
|
|||
will be added. A new picking will be created if ommitted.
|
||||
:return: True
|
||||
"""
|
||||
move_obj = self.pool.get('stock.move')
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
|
||||
proc_ids = []
|
||||
for line in order_lines:
|
||||
if line.state == 'done':
|
||||
|
@ -768,13 +772,13 @@ class sale_order(osv.osv):
|
|||
if line.product_id:
|
||||
if line.product_id.product_tmpl_id.type in ('product', 'consu'):
|
||||
if not picking_id:
|
||||
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
|
||||
move_id = self.pool.get('stock.move').create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args))
|
||||
picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
|
||||
move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args))
|
||||
else:
|
||||
# a service has no stock move
|
||||
move_id = False
|
||||
|
||||
proc_id = self.pool.get('procurement.order').create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
|
||||
proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
|
||||
proc_ids.append(proc_id)
|
||||
line.write({'procurement_id': proc_id})
|
||||
|
||||
|
@ -784,12 +788,12 @@ class sale_order(osv.osv):
|
|||
for pick in order.picking_ids:
|
||||
for move in pick.move_lines:
|
||||
if move.state == 'cancel':
|
||||
mov_ids = self.pool.get('stock.move').search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
|
||||
mov_ids = move_obj.search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
|
||||
if mov_ids:
|
||||
for mov in move_obj.browse(cr, uid, mov_ids):
|
||||
# FIXME: the following seems broken: what if move_id doesn't exist? What if there are several mov_ids? Shouldn't that be a sum?
|
||||
self.pool.get('stock.move').write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||
self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||
move_obj.write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||
procurement_obj.write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
if picking_id:
|
||||
|
|
Loading…
Reference in New Issue