[FIX] mrp: properly apply location chaining rules after exploding set/phantom BoM

The explosion of a kit product typically produces a few
new stock moves, which must go through the normal
location chaining process. This was not the case, only
the kit move was properly chained.

bzr revid: odo@openerp.com-20110922090759-ukxz7eu8q388jk38
This commit is contained in:
Olivier Dony 2011-09-22 11:07:59 +02:00
parent b8fc49476d
commit ef4795dbe6
1 changed files with 9 additions and 10 deletions

View File

@ -46,6 +46,7 @@ class StockMove(osv.osv):
procurement_obj = self.pool.get('procurement.order')
product_obj = self.pool.get('product.product')
wf_service = netsvc.LocalService("workflow")
processed_ids = [move.id]
if move.product_id.supply_method == 'produce' and move.product_id.procure_method == 'make_to_order':
bis = bom_obj.search(cr, uid, [
('product_id','=',move.product_id.id),
@ -74,6 +75,7 @@ class StockMove(osv.osv):
'procurements': [],
}
mid = move_obj.copy(cr, uid, move.id, default=valdef)
processed_ids.append(mid)
prodobj = product_obj.browse(cr, uid, line['product_id'], context=context)
proc_id = procurement_obj.create(cr, uid, {
'name': (move.picking_id.origin or ''),
@ -98,7 +100,7 @@ class StockMove(osv.osv):
for m in procurement_obj.search(cr, uid, [('move_id','=',move.id)], context):
wf_service.trg_validate(uid, 'procurement.order', m, 'button_confirm', cr)
wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr)
return True
return processed_ids
def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None):
""" Consumed product with specific quatity from specific source location.
@ -154,16 +156,13 @@ class StockPicking(osv.osv):
#
# Explode picking by replacing phantom BoMs
#
def action_explode(self, cr, uid, picks, *args):
""" Explodes picking by replacing phantom BoMs
@param picks: Picking ids.
@param *args: Arguments
@return: Picking ids.
"""
def action_explode(self, cr, uid, move_ids, *args):
"""Explodes moves by expanding kit components"""
move_obj = self.pool.get('stock.move')
for move in move_obj.browse(cr, uid, picks):
move_obj._action_explode(cr, uid, move)
return picks
todo = move_ids[:]
for move in move_obj.browse(cr, uid, move_ids):
todo.extend(move_obj._action_explode(cr, uid, move))
return list(set(todo))
StockPicking()