From 27142662c64d09f23335efe3d3e695ed44def1e2 Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Mon, 20 Jul 2026 19:12:36 +0200 Subject: [PATCH] [18.0][OU-FIX] stock: fill default locations of archived picking types too fill_stock_picking_type_default_locations() searches the picking types with a missing default location and recomputes them, but the search honors active_test, so archived picking types are silently skipped and the SET NOT NULL on default_location_src_id/default_location_dest_id (both required since 18.0) keeps failing on any database that has archived picking types with empty defaults. Search with active_test=False so the fill covers them as well. --- .../scripts/stock/18.0.1.1/end-migration.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openupgrade_scripts/scripts/stock/18.0.1.1/end-migration.py b/openupgrade_scripts/scripts/stock/18.0.1.1/end-migration.py index 6f1449d6639b..b70813c9119b 100644 --- a/openupgrade_scripts/scripts/stock/18.0.1.1/end-migration.py +++ b/openupgrade_scripts/scripts/stock/18.0.1.1/end-migration.py @@ -4,12 +4,18 @@ def fill_stock_picking_type_default_locations(env): - picking_types = env["stock.picking.type"].search( - [("default_location_src_id", "=", False)] + # active_test=False: archived picking types need the fill too, otherwise + # the SET NOT NULL on both columns (required since 18.0) keeps failing + picking_types = ( + env["stock.picking.type"] + .with_context(active_test=False) + .search([("default_location_src_id", "=", False)]) ) picking_types._compute_default_location_src_id() - picking_types = env["stock.picking.type"].search( - [("default_location_dest_id", "=", False)] + picking_types = ( + env["stock.picking.type"] + .with_context(active_test=False) + .search([("default_location_dest_id", "=", False)]) ) picking_types._compute_default_location_dest_id()