[FIX] mrp: fix issue introduced by rev b9cdce1

If copy=True for production_id, a move created from a push rule will be added
in the list of Product Produced. Therefore, we must set manually the value of
production_id of the scrapped moves.

opw-643877
This commit is contained in:
Nicolas Martinelli 2015-07-02 16:35:18 +02:00
parent 3062b66d21
commit 1ab007a843
1 changed files with 6 additions and 4 deletions

View File

@ -31,7 +31,7 @@ class StockMove(osv.osv):
_inherit = 'stock.move'
_columns = {
'production_id': fields.many2one('mrp.production', 'Production Order for Produced Products', select=True),
'production_id': fields.many2one('mrp.production', 'Production Order for Produced Products', select=True, copy=False),
'raw_material_production_id': fields.many2one('mrp.production', 'Production Order for Raw Materials', select=True),
'consumed_for': fields.many2one('stock.move', 'Consumed for', help='Technical field used to make the traceability of produced products'),
}
@ -192,6 +192,8 @@ class StockMove(osv.osv):
quantity_rest_uom = move.product_uom_qty - self.pool.get("product.uom")._compute_qty_obj(cr, uid, move.product_id.uom_id, product_qty, move.product_uom)
if float_compare(quantity_rest_uom, 0, precision_rounding=move.product_uom.rounding) != 0:
new_mov = self.split(cr, uid, move, quantity_rest, context=context)
if move.production_id:
self.write(cr, uid, [new_mov], {'production_id': move.production_id.id}, context=context)
res.append(new_mov)
vals = {'restrict_lot_id': restrict_lot_id,
'restrict_partner_id': restrict_partner_id,
@ -223,9 +225,9 @@ class StockMove(osv.osv):
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
for prod_id in production_ids:
production_obj.signal_workflow(cr, uid, [prod_id], 'button_produce')
for new_move in new_moves:
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
res.append(new_move)
if move.production_id.id:
self.write(cr, uid, new_moves, {'production_id': move.production_id.id}, context=context)
res.append(new_moves)
return res
def write(self, cr, uid, ids, vals, context=None):