From a29ec8008201ed7ffaed32fd3960cd5ea76c5ff6 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 9 Nov 2017 11:23:33 +0100 Subject: [PATCH] [FIX] stock: _assign_picking Commit[1] tried to improve the usability of the pick + pack + ship + a fixed procurement group scenario by erasing the origin value on the groupped ship that refered wrongly to only the first downstream document (and in fact refered to multiple). We forgot the scenario into which we add a sale order line. In this scenario, we also go through `_assign_picking` and, if an existing open picking is found, we also wiped its partner and origin value, which was indeed wrong. We fix this scenario by being more precise on the erasing condition. [1] 4a5f07654f6d4252f73253d26979cf97bbf7f11b --- addons/stock/models/stock_move.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index b51495cb3d7..5ec43a2728b 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -652,13 +652,14 @@ class StockMove(models.Model): ('printed', '=', False), ('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])], limit=1) if picking: - # If a picking is found, we'll append `move` to its move list and thus its - # `partner_id` and `ref` field will refer to multiple records. In this - # case, we chose to wipe them. - picking.write({ - 'partner_id': False, - 'origin': False, - }) + if picking.partner_id.id != move.partner_id.id or picking.origin != move.origin: + # If a picking is found, we'll append `move` to its move list and thus its + # `partner_id` and `ref` field will refer to multiple records. In this + # case, we chose to wipe them. + picking.write({ + 'partner_id': False, + 'origin': False, + }) else: recompute = True picking = Picking.create(move._get_new_picking_values())