Skip to content

[17.0][OU-FIX] repair: fallback picking type for repairs outside warehouses#7

Open
eantones wants to merge 1 commit into
17.0from
17.0-fix-repair-picking-type-fallback
Open

[17.0][OU-FIX] repair: fallback picking type for repairs outside warehouses#7
eantones wants to merge 1 commit into
17.0from
17.0-fix-repair-picking-type-fallback

Conversation

@eantones

@eantones eantones commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

fill_repair_picking_type() (repair 17.0.1.0 post-migration) maps repair orders to their warehouse's new repair picking type via repair_order.location_id → stock_location.warehouse_id. Repair orders whose location does not belong to any warehouse — standalone workshop locations, customer/transit/virtual locations — are not covered by that UPDATE and keep referencing the temporary location and picking type created in pre-migration.

The cleanup unlink() of those temporary records then crashes the whole 16→17 upgrade:

psycopg2.errors.NotNullViolation: null value in column "location_dest_id" of relation "repair_order" violates not-null constraint
CONTEXT: SQL statement "UPDATE ONLY public.repair_order SET location_dest_id = NULL WHERE $1 = location_dest_id"

(the FK's ON DELETE SET NULL collides with the NOT NULL the ORM adds for these required fields.)

On the database where this was found, 97% of repair orders (26,771 / 27,663) used workshop locations outside any warehouse hierarchy.

Fix

After the warehouse-based UPDATE and before deleting the temporary records, assign the remaining rows a per-company fallback: the company's first active warehouse repair type (same columns upstream maps: location_dest_id, parts_location_id, recycle_location_id).

fill_repair_picking_type() maps repair orders to their warehouse's new
repair picking type by joining repair_order.location_id ->
stock_location.warehouse_id. Repairs whose location does not belong to
any warehouse (standalone workshop locations, customer/transit/virtual
locations) are left referencing the temporary location and picking type
created in pre-migration, and the cleanup unlink crashes: the FK
ON DELETE SET NULL collides with the NOT NULL constraint the ORM adds
for these required fields.

Add a per-company fallback that assigns the first active warehouse's
repair type to the remaining rows before deleting the temporary records.
@eantones eantones added the upstream-candidate Generic fix, submit to OCA/OpenUpgrade when validated label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-candidate Generic fix, submit to OCA/OpenUpgrade when validated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant