[17.0][OU-FIX] repair: fallback picking type for repairs outside warehouses#7
Open
eantones wants to merge 1 commit into
Open
[17.0][OU-FIX] repair: fallback picking type for repairs outside warehouses#7eantones wants to merge 1 commit into
eantones wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
fill_repair_picking_type()(repair 17.0.1.0 post-migration) maps repair orders to their warehouse's new repair picking type viarepair_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:(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).