From 32b3e1bb6a5c30ccb19206a2ed0ef229ca82843a Mon Sep 17 00:00:00 2001 From: snd Date: Fri, 27 Oct 2023 17:21:48 +0200 Subject: [PATCH] [FIX] stock: receipt transfers almost always ready Incoming picking should almost never be in a waiting ('confirmed') state. So we check if the location bypasses reservation and that no move is in MTO. Changing the main_flow_tour because removing the "Waiting" status from incoming picking forms makes it unable to find "Ready" in Mobile UI. closes odoo/odoo#140180 Signed-off-by: William Henrotin (whe) --- addons/stock/models/stock_picking.py | 10 +++++++--- addons/stock/views/stock_picking_views.xml | 3 ++- .../test_main_flows/static/tests/tours/main_flow.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 73a4a38f421..c313fbdcf15 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -635,6 +635,7 @@ class Picking(models.Model): - Ready: if the picking is ready to be sent so if: - (a) all quantities are reserved or if - (b) some quantities could be reserved and the shipping policy is "as soon as possible" + - (c) it's an incoming picking - Done: if the picking is done. - Cancelled: if the picking is cancelled ''' @@ -663,11 +664,14 @@ class Picking(models.Model): else: picking.state = 'done' else: - relevant_move_state = self.env['stock.move'].browse(picking_move_lines[picking_id])._get_relevant_state_among_moves() - if relevant_move_state == 'partially_available': + if picking.location_id.should_bypass_reservation() and all(m.procure_method == 'make_to_stock' for m in picking.move_ids): picking.state = 'assigned' else: - picking.state = relevant_move_state + relevant_move_state = self.env['stock.move'].browse(picking_move_lines[picking_id])._get_relevant_state_among_moves() + if relevant_move_state == 'partially_available': + picking.state = 'assigned' + else: + picking.state = relevant_move_state @api.depends('move_ids.state', 'move_ids.date', 'move_type') def _compute_scheduled_date(self): diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index caff4ca6ffe..73facac1bde 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -156,7 +156,8 @@