Skip to content

Commit 0caa44c

Browse files
author
Ethan Vincent
committed
[FIX] stock: append move origin to picking instead of clearing
**Current behavior:** During the assignment of a picking, if any of its moves have an origin that does not match its own, the origin will be cleared altogether. **Expected behavior:** The different origin should be appended to the existing origin string (as is done in batch replenishment, for example). **Steps to reproduce:** 1. Create 2 products, create a secondary warehouse 2. Create an orderpoint for each product, make the route on both of them the (first?) pointed to by `resupply_route_ids` on the primary warehouse 3. Set `qty_to_order` 1 on each of the orderpoints, and one at a time click the 'Order' button 4. The move generated for each replenishment action will ultimately be added to a single picking -> in the end see that its `origin` field is cleared **Cause of the issue:** We currently decide to clear the picking origin during assignment if any of its moves have a different origin. **Fix:** Instead, append the different origin string to the picking. opw-4749519 closes odoo#212674 Signed-off-by: William Henrotin (whe) <[email protected]>
1 parent 0f0a069 commit 0caa44c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

addons/stock/models/stock_move.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,14 @@ def _assign_picking_values(self, picking):
14041404
if any(picking.partner_id != m.partner_id for m in self):
14051405
vals['partner_id'] = False
14061406
if any(picking.origin != m.origin for m in self):
1407-
vals['origin'] = False
1407+
current_origins = set(picking.origin.split(',') + [False]) if picking.origin else {False}
1408+
vals['origin'] = picking.origin
1409+
for move in self:
1410+
if move.origin not in current_origins:
1411+
if not vals['origin']:
1412+
vals['origin'] = move.origin
1413+
else:
1414+
vals['origin'] += f',{move.origin}'
14081415
return vals
14091416

14101417
def _assign_picking_post_process(self, new=False):

addons/stock/tests/test_old_rules.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ def test_procurement_group_merge(self):
414414
self.assertEqual(picking_pick.partner_id.id, procurement_group1.partner_id.id)
415415
self.assertEqual(picking_pick.origin, move1.group_id.name)
416416

417-
# second out move, the "pick" picking should have lost its partner and origin
417+
# second out move, the "pick" picking should have lost its partner and have its origin updated
418418
move2._action_confirm()
419419
self.assertEqual(picking_pick.partner_id.id, False)
420-
self.assertEqual(picking_pick.origin, False)
420+
self.assertEqual(picking_pick.origin, f'{move1.group_id.name},{move2.group_id.name}')
421421

422422
def test_fixed_procurement_01(self):
423423
""" Run a procurement for 5 products when there are only 4 in stock then
@@ -601,10 +601,10 @@ def test_pick_ship_1(self):
601601
self.assertEqual(picking_pick.partner_id.id, procurement_group1.partner_id.id)
602602
self.assertEqual(picking_pick.origin, move1.group_id.name)
603603

604-
# second out move, the "pick" picking should have lost its partner and origin
604+
# second out move, the "pick" picking should have lost its partner and have its origin updated
605605
move2._action_confirm()
606606
self.assertEqual(picking_pick.partner_id.id, False)
607-
self.assertEqual(picking_pick.origin, False)
607+
self.assertEqual(picking_pick.origin, f'{move1.group_id.name},{move2.group_id.name}')
608608

609609
def test_propagate_cancel_in_pull_setup(self):
610610
"""

0 commit comments

Comments
 (0)