[Subcontracting] Fix subcontracting transfer order issues and add field modification protection#8563
Conversation
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThis PR moves subcontracting transfer logic into SuggestionsS1 - Grant execute permission to new codeunits S2 - Protect persisted field changes, not only validation Risk assessment and necessityRisk: This is high regression surface because subcontracting purchase lines, transfer orders, reservations, WIP ledger entries, and production order components are all involved. The new refactor centralizes transfer behavior in Necessity: The transfer-order fixes appear necessary, and tests are present for duplicate/recreate and reservation scenarios. The scope is broad for a bug PR because it combines transfer fixes, field protection, message changes, and a refactor across multiple AB links; that can be acceptable only if the object permissions and end-to-end guard coverage are made complete. Work items were not independently verified.
|
|
Please review the suggestions |
…main-WIP_transfer_issues_v2
|
FlowField now includes closed ILEsThe Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Flowfield now returns total-transferred, not remaining stockRemoving Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Adjust action missing InherentPermissionsAdjustProdOrderLineQuantity() modifies Prod. Order Line records from an ErrorInfo action but declares no InherentPermissions and the codeunit has no Permissions property. Users who can work with subcontracting purchase lines but lack direct modify rights on production order lines will receive a permission error when they choose the guided fix. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Whse adjust action missing InherentPermissionsThe warehouse receipt AdjustProdOrderLineQuantity() also updates Prod. Order Line without declaring InherentPermissions or codeunit-level object permissions. The recovery action will fail at runtime for any user without direct production order modify rights. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Over-delivery check uses total qty not remainingCheckOverDeliveryQty() and AdjustProdOrderLineQuantity() compare against ProdOrderLine.Quantity instead of ProdOrderLine."Remaining Quantity". After partial output has already been posted, the check passes for quantities that still exceed what remains, and the adjustment calculates the wrong delta to add to the production order total. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Whse over-delivery check uses total qtyCheckOverDelivery() compares WarehouseReceiptLine.Quantity against ProdOrderLine.Quantity, and the adjustment at line 263 repeats the same incorrect comparison. On partially processed production orders this allows genuine over-deliveries to slip through undetected. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Open-anyway action bound to wrong codeunitThe "Open item tracking anyway" action in the warehouse receipt mismatch dialog is wired to codeunit "Subc. Purchase Line Ext" instead of the current file's handler. That handler does not have access to the stored Warehouse Receipt Line SystemId in CustomDimensions, so tracking is reopened with purchase-line semantics rather than the receipt-line quantities that triggered the error. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
What & why
Bug Fixes
Transferred qty not counted correctly — Removed Open filter from the component FlowField so posted transfer entries are included in the calculation.
Duplicate return TO not blocked — Fixed TransferLineAlreadyExists logic so creating a second return transfer order is correctly prevented.
Missing Subc. Location Code error unclear — Replaced generic TestField error with a descriptive message naming the vendor.
Field Modification Protection
Purchase Line fields locked — Blocked changing Quantity, No., Location Code, Bin Code, Variant Code, and Unit of Measure Code on subcontracting purchase lines when transfer orders exist or stock is at the subcontractor.
Transfer Line fields locked — Blocked changing Item No., Variant Code, and Quantity on transfer lines linked to a production order.
Transfer Header fields locked — Blocked changing Transfer-from/to Code on subcontracting transfer headers with linked lines.
Code Organization
Extracted transfer procedures — Moved all transfer-related logic from Subcontracting Management into a new dedicated Subc. Transfer Management codeunit for better separation of concerns.
Linked work
Fixes AB#630809, AB#630810, AB#630811, AB#636821, AB#636822, AB#634269