[FIX] mrp: chain product move and MO locations
authorJulien Legros <jle@odoo.com>
Tue, 4 Nov 2014 17:07:59 +0000 (18:07 +0100)
committerJulien Legros <jle@odoo.com>
Wed, 5 Nov 2014 11:44:02 +0000 (12:44 +0100)
When validating a SO containing a `make to stock` + `manufacture` product
(with bom + orderpoint), we have the following stock moves:
* Product move
* Manufacturing order
Selling 1 such product would yield 2 as incoming quantity, an
inconsistency that this commit solves by setting the location_id of the
product move to the MO's location_dest_id (in the same fashion that
the create_pickings method does in an mts/buy case)

opw-616229

addons/mrp/mrp.py

index e8e1887..72226e9 100644 (file)
@@ -993,6 +993,8 @@ class mrp_production(osv.osv):
             'state': 'waiting',
             'company_id': production.company_id.id,
         }
+        if production.move_prod_id:
+            production.move_prod_id.write({'location_id': destination_location_id})
         move_id = stock_move.create(cr, uid, data, context=context)
         production.write({'move_created_ids': [(6, 0, [move_id])]}, context=context)
         return move_id