Merge pull request #3321 from odoo-dev/8.0-wmsmrpfixes-jco
[FIX] When extra move for consumption lines, copy lot and when producing...
This commit is contained in:
commit
b962c5810c
|
@ -915,9 +915,19 @@ class mrp_production(osv.osv):
|
||||||
lot_id = False
|
lot_id = False
|
||||||
if wiz:
|
if wiz:
|
||||||
lot_id = wiz.lot_id.id
|
lot_id = wiz.lot_id.id
|
||||||
new_moves = stock_mov_obj.action_consume(cr, uid, [produce_product.id], (subproduct_factor * production_qty_uom),
|
qty = min(subproduct_factor * production_qty_uom, produce_product.product_qty) #Needed when producing more than maximum quantity
|
||||||
|
new_moves = stock_mov_obj.action_consume(cr, uid, [produce_product.id], qty,
|
||||||
location_id=produce_product.location_id.id, restrict_lot_id=lot_id, context=context)
|
location_id=produce_product.location_id.id, restrict_lot_id=lot_id, context=context)
|
||||||
stock_mov_obj.write(cr, uid, new_moves, {'production_id': production_id}, context=context)
|
stock_mov_obj.write(cr, uid, new_moves, {'production_id': production_id}, context=context)
|
||||||
|
remaining_qty = subproduct_factor * production_qty_uom - qty
|
||||||
|
if remaining_qty: # In case you need to make more than planned
|
||||||
|
#consumed more in wizard than previously planned
|
||||||
|
extra_move_id = stock_mov_obj.copy(cr, uid, produce_product.id, default={'state': 'confirmed',
|
||||||
|
'product_uom_qty': remaining_qty,
|
||||||
|
'production_id': production_id}, context=context)
|
||||||
|
if extra_move_id:
|
||||||
|
stock_mov_obj.action_done(cr, uid, [extra_move_id], context=context)
|
||||||
|
|
||||||
if produce_product.product_id.id == production.product_id.id:
|
if produce_product.product_id.id == production.product_id.id:
|
||||||
main_production_move = produce_product.id
|
main_production_move = produce_product.id
|
||||||
|
|
||||||
|
@ -936,13 +946,16 @@ class mrp_production(osv.osv):
|
||||||
if consume['product_id'] != raw_material_line.product_id.id:
|
if consume['product_id'] != raw_material_line.product_id.id:
|
||||||
continue
|
continue
|
||||||
consumed_qty = min(remaining_qty, raw_material_line.product_qty)
|
consumed_qty = min(remaining_qty, raw_material_line.product_qty)
|
||||||
stock_mov_obj.action_consume(cr, uid, [raw_material_line.id], consumed_qty, raw_material_line.location_id.id, restrict_lot_id=consume['lot_id'], consumed_for=main_production_move, context=context)
|
stock_mov_obj.action_consume(cr, uid, [raw_material_line.id], consumed_qty, raw_material_line.location_id.id,
|
||||||
|
restrict_lot_id=consume['lot_id'], consumed_for=main_production_move, context=context)
|
||||||
remaining_qty -= consumed_qty
|
remaining_qty -= consumed_qty
|
||||||
if remaining_qty:
|
if remaining_qty:
|
||||||
#consumed more in wizard than previously planned
|
#consumed more in wizard than previously planned
|
||||||
product = self.pool.get('product.product').browse(cr, uid, consume['product_id'], context=context)
|
product = self.pool.get('product.product').browse(cr, uid, consume['product_id'], context=context)
|
||||||
extra_move_id = self._make_consume_line_from_data(cr, uid, production, product, product.uom_id.id, remaining_qty, False, 0, context=context)
|
extra_move_id = self._make_consume_line_from_data(cr, uid, production, product, product.uom_id.id, remaining_qty, False, 0, context=context)
|
||||||
if extra_move_id:
|
if extra_move_id:
|
||||||
|
if consume['lot_id']:
|
||||||
|
stock_mov_obj.write(cr, uid, [extra_move_id], {'restrict_lot_id': consume['lot_id']}, context=context)
|
||||||
stock_mov_obj.action_done(cr, uid, [extra_move_id], context=context)
|
stock_mov_obj.action_done(cr, uid, [extra_move_id], context=context)
|
||||||
|
|
||||||
self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
|
self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
|
||||||
|
|
Loading…
Reference in New Issue