STOCK: fix split lot production
bzr revid: ced-531ed6f80ae1fb27a80d40e1cb6ec331e750178b
This commit is contained in:
parent
aff1caa0de
commit
5198ecf2ec
|
@ -60,6 +60,7 @@ def _track_lines(self, cr, uid, data, context):
|
||||||
prodlot_obj = pooler.get_pool(cr.dbname).get('stock.production.lot')
|
prodlot_obj = pooler.get_pool(cr.dbname).get('stock.production.lot')
|
||||||
move_obj = pooler.get_pool(cr.dbname).get('stock.move')
|
move_obj = pooler.get_pool(cr.dbname).get('stock.move')
|
||||||
sequence = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid, 'stock.lot.serial')
|
sequence = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid, 'stock.lot.serial')
|
||||||
|
production_obj = pooler.get_pool(cr.dbname).get('mrp.production')
|
||||||
if data['form']['tracking_prefix']:
|
if data['form']['tracking_prefix']:
|
||||||
sequence=data['form']['tracking_prefix']+'/'+(sequence or '')
|
sequence=data['form']['tracking_prefix']+'/'+(sequence or '')
|
||||||
if not sequence:
|
if not sequence:
|
||||||
|
@ -78,14 +79,17 @@ def _track_lines(self, cr, uid, data, context):
|
||||||
'product_qty': quantity,
|
'product_qty': quantity,
|
||||||
'product_uos_qty': uos_qty,
|
'product_uos_qty': uos_qty,
|
||||||
}
|
}
|
||||||
|
new_move = []
|
||||||
for idx in range(int(move.product_qty//quantity)):
|
for idx in range(int(move.product_qty//quantity)):
|
||||||
if idx:
|
if idx:
|
||||||
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
|
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
|
||||||
|
new_move.append(current_move)
|
||||||
else:
|
else:
|
||||||
current_move = move.id
|
current_move = move.id
|
||||||
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx})
|
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx})
|
||||||
update_val['prodlot_id'] = new_prodlot
|
update_val['prodlot_id'] = new_prodlot
|
||||||
move_obj.write(cr, uid, [current_move], update_val)
|
move_obj.write(cr, uid, [current_move], update_val)
|
||||||
|
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
|
||||||
|
|
||||||
if quantity_rest > 0:
|
if quantity_rest > 0:
|
||||||
idx = int(move.product_qty//quantity)
|
idx = int(move.product_qty//quantity)
|
||||||
|
@ -93,12 +97,20 @@ def _track_lines(self, cr, uid, data, context):
|
||||||
update_val['product_uos_qty']=uos_qty_rest
|
update_val['product_uos_qty']=uos_qty_rest
|
||||||
if idx:
|
if idx:
|
||||||
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
|
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
|
||||||
|
new_move.append(current_move)
|
||||||
else:
|
else:
|
||||||
current_move = move.id
|
current_move = move.id
|
||||||
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx})
|
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx})
|
||||||
update_val['prodlot_id'] = new_prodlot
|
update_val['prodlot_id'] = new_prodlot
|
||||||
move_obj.write(cr, uid, [current_move], update_val)
|
move_obj.write(cr, uid, [current_move], update_val)
|
||||||
|
|
||||||
|
products = production_obj.read(cr, uid, production_ids, ['move_lines'])
|
||||||
|
for p in products:
|
||||||
|
for new in new_move:
|
||||||
|
if new not in p['move_lines']:
|
||||||
|
p['move_lines'].append(new)
|
||||||
|
production_obj.write(cr, uid, [p['id']], {'move_lines': [(6, 0, p['move_lines'])]})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wizard_track_move(wizard.interface):
|
class wizard_track_move(wizard.interface):
|
||||||
|
|
Loading…
Reference in New Issue