Skip to content

[18.0][OU-FIX] stock: fill default locations of archived picking types too#24

Open
eantones wants to merge 1 commit into
18.0from
18.0-fix-stock-picking-type-fill-archived
Open

[18.0][OU-FIX] stock: fill default locations of archived picking types too#24
eantones wants to merge 1 commit into
18.0from
18.0-fix-stock-picking-type-fill-archived

Conversation

@eantones

Copy link
Copy Markdown
Member

Problem

stock.picking.type.default_location_src_id / default_location_dest_id are required since 18.0 (stored computes). The stock 18.0.1.1 end-migration already fills the missing ones:

picking_types = env["stock.picking.type"].search(
    [("default_location_src_id", "=", False)]
)
picking_types._compute_default_location_src_id()

but search() honors active_test, so archived picking types are silently skipped. On any database carrying archived picking types with empty defaults, the fill only cures the active ones and the schema constraint keeps failing on every update:

odoo.schema: Table 'stock_picking_type': unable to set NOT NULL on column 'default_location_src_id'
odoo.schema: Table 'stock_picking_type': unable to set NOT NULL on column 'default_location_dest_id'

Observed on a real 14.0→18.0 chain: 74 active picking types with empty defaults were filled fine, while 49 archived ones (internal + mrp_operation, all with a warehouse) stayed NULL and blocked the SET NOT NULL.

Fix

Run both searches with_context(active_test=False) so archived picking types get the same compute-based fill.

…s 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.
@eantones eantones added the oca-candidate Contains commits of ours that will be proposed to OCA at submit time. label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oca-candidate Contains commits of ours that will be proposed to OCA at submit time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant