From b42e9c4547b174e5cf88458a6c1b72e456cd9093 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 19 Mar 2020 12:21:46 +0000 Subject: [PATCH] [FIX] stock: immediate transfer - Install Purchase - Activate multi-step routes, multi warehouses and packaging - Create 2 wharehouses WH1 et WH2 - 'WH1: Receipts' and 'WH2: Receipts' Show Detailed Operations: True Pre-fill Detailed Operations: True Move Entire Packages: True - 'WH1: Internal Transfers' Show Detailed Operations: True Move Entire Packages: True - Create a route 'WH1 -> WH2': Applicable On WH1 Rule: Action: Push To Operation Type: WH2: Receipts Source Location: Virtual Locations/Inter Company Transit Destination Locaion: WH2/Stock Automatic Move: Manual Operation - Create a PO for 100 units of P1 and P2, validate - Go to the picking, set 40 units done for P1 and P2 => Put in Pack - Set 60 units done for P1 and P2 => Put in Pack - Validate - Create an Internal Transfer in WH1: Operation Type: WH1: Internal Transfers Source Location: WH1/Stock Destination Location: Virtual Locations/Inter Company Transit - Add the 2 packages previously created, save and validate 4 pickings are created in 'WH2: Receipts': 40 P1, 40 P2, 60 P1 and 60 P2. There should only be one picking with the 2 packages. The issue is similar to 2d4a743600f4501bbbed60a063ea2a87f1bce075: the `default_immediate_transfer` context key pollutes the creation of the pickings. opw-2197720 closes odoo/odoo#48038 X-original-commit: 6e5cfb62b43f0781c246e9a27259e63199203221 Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_picking.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 2853971c8a1..3d9276c7061 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -989,6 +989,10 @@ class Picking(models.Model): if the picking is a planned transfer and one of its move was added after the initial call to `action_confirm`. Note that `action_confirm` will only work on draft moves. """ + # Clean-up the context key to avoid forcing the creation of immediate transfers. + ctx = dict(self.env.context) + ctx.pop('default_immediate_transfer', None) + self = self.with_context(ctx) for picking in self: if picking.state in ('done', 'cancel'): continue