-
Notifications
You must be signed in to change notification settings - Fork 455
[Main]- Production order can be deleted with registered unconsumed warehouse picks #11261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1155,7 +1155,8 @@ table 5407 "Prod. Order Component" | |
| TestField("Qty. on Transfer Order (Base)", 0); | ||
| end; | ||
| #endif | ||
| ConfirmDeletion(); | ||
| if not CalledFromHeader then | ||
| CheckPickedQtyBeforeDeletion(); | ||
| end; | ||
|
|
||
| ProdOrderWarehouseMgt.ProdComponentDelete(Rec); | ||
|
|
@@ -1254,7 +1255,7 @@ table 5407 "Prod. Order Component" | |
| #pragma warning restore AA0470 | ||
| Text99000009: Label 'Automatic reservation is not possible.\Do you want to reserve items manually?'; | ||
| #pragma warning restore AA0074 | ||
| ConfirmDeleteQst: Label '%1 = %2 is greater than %3 = %4. If you delete the %5, the items will remain in the operation area until you put them away.\Any related item tracking information defined during the pick process will be deleted.\Do you still want to delete the %5?', Comment = '%1 = FieldCaption("Qty. Picked"), %2 = "Qty. Picked", %3 = Qty. Posted, %4 = ("Expected Quantity" - "Remaining Quantity"), %5 = TableCaption'; | ||
| CannotDeleteWithPickedQtyErr: Label 'You cannot delete the production order because one or more components have a picked quantity that has not been consumed. Consume or return the picked quantity before deleting the production order.'; | ||
| CannotAutoReserveErr: Label 'Quantity %1 in line %2 cannot be reserved automatically.', Comment = '%1 - quantity, %2 - line number'; | ||
| #pragma warning disable AA0470 | ||
| ProgressMsg: Label 'Reserving inventory...\#1##############\@2@@@@@'; | ||
|
|
@@ -2341,30 +2342,10 @@ table 5407 "Prod. Order Component" | |
| end; | ||
| end; | ||
|
|
||
| local procedure ConfirmDeletion() | ||
| internal procedure CheckPickedQtyBeforeDeletion() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing the previous confirm-based deletion check with a hard Error() is a user-visible breaking change. Before this change, users could still proceed with deletion after acknowledging the warning, and locations whose production warehouse handling was configured as No Warehouse Handling bypassed the check entirely. Preserve that compatibility path or stage the stricter behavior as an explicit migration, otherwise existing production-order, line, and component deletion flows will start failing immediately. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6 |
||
| begin | ||
| if CalledFromHeader then | ||
| exit; | ||
|
|
||
| if ("Expected Quantity" - "Remaining Quantity") < "Qty. Picked" then begin | ||
| if "Location Code" <> '' then begin | ||
| GetLocation("Location Code"); | ||
| if Location."Prod. Output Whse. Handling" = Location."Prod. Consump. Whse. Handling"::"No Warehouse Handling" then | ||
| exit; | ||
| end; | ||
|
|
||
| if not Confirm( | ||
| StrSubstNo( | ||
| ConfirmDeleteQst, | ||
| FieldCaption("Qty. Picked"), | ||
| "Qty. Picked", | ||
| 'Qty. Posted', | ||
| ("Expected Qty. (Base)" - "Remaining Qty. (Base)"), | ||
| TableCaption), | ||
| false) | ||
| then | ||
| Error(''); | ||
| end; | ||
| if ("Expected Qty. (Base)" - "Remaining Qty. (Base)") < "Qty. Picked (Base)" then | ||
| Error(CannotDeleteWithPickedQtyErr); | ||
| end; | ||
|
|
||
| procedure SuspendDeletionCheck(Suspend: Boolean) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1022,7 +1022,9 @@ table 5407 "Prod. Order Component" | |
| if not ItemLedgEntry.IsEmpty() then | ||
| Error(Text99000000, "Item No.", "Line No."); | ||
|
|
||
| ConfirmDeletion(); | ||
|
|
||
| if not CalledFromHeader then | ||
| CheckPickedQtyBeforeDeletion(); | ||
| end; | ||
|
|
||
| ProdOrderWarehouseMgt.ProdComponentDelete(Rec); | ||
|
|
@@ -1121,7 +1123,7 @@ table 5407 "Prod. Order Component" | |
| #pragma warning restore AA0470 | ||
| Text99000009: Label 'Automatic reservation is not possible.\Do you want to reserve items manually?'; | ||
| #pragma warning restore AA0074 | ||
| ConfirmDeleteQst: Label '%1 = %2 is greater than %3 = %4. If you delete the %5, the items will remain in the operation area until you put them away.\Any related item tracking information defined during the pick process will be deleted.\Do you still want to delete the %5?', Comment = '%1 = FieldCaption("Qty. Picked"), %2 = "Qty. Picked", %3 = Qty. Posted, %4 = ("Expected Quantity" - "Remaining Quantity"), %5 = TableCaption'; | ||
| CannotDeleteWithPickedQtyErr: Label 'You cannot delete the production order because one or more components have a picked quantity that has not been consumed. Consume or return the picked quantity before deleting the production order.'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new CannotDeleteWithPickedQtyErr text says the user cannot delete "the production order", but this label is raised from Prod. Order Component deletion and is also reused by the new Prod. Order Line deletion path. That makes the blocked operation read incorrectly for component and line deletes. Tailor the message to the actual delete target, or pass the caller caption into the shared check so each path reports the right entity. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6 |
||
| CannotAutoReserveErr: Label 'Quantity %1 in line %2 cannot be reserved automatically.', Comment = '%1 - quantity, %2 - line number'; | ||
| #pragma warning disable AA0470 | ||
| ProgressMsg: Label 'Reserving inventory...\#1##############\@2@@@@@'; | ||
|
|
@@ -2205,30 +2207,10 @@ table 5407 "Prod. Order Component" | |
| end; | ||
| end; | ||
|
|
||
| local procedure ConfirmDeletion() | ||
| internal procedure CheckPickedQtyBeforeDeletion() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing the previous confirm-based deletion check with a hard Error() is a user-visible breaking change. Before this change, users could still proceed with deletion after acknowledging the warning, and locations whose production warehouse handling was configured as No Warehouse Handling bypassed the check entirely. Preserve that compatibility path or stage the stricter behavior as an explicit migration, otherwise existing production-order, line, and component deletion flows will start failing immediately. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6 |
||
| begin | ||
| if CalledFromHeader then | ||
| exit; | ||
|
|
||
| if ("Expected Quantity" - "Remaining Quantity") < "Qty. Picked" then begin | ||
| if "Location Code" <> '' then begin | ||
| GetLocation("Location Code"); | ||
| if Location."Prod. Output Whse. Handling" = Location."Prod. Consump. Whse. Handling"::"No Warehouse Handling" then | ||
| exit; | ||
| end; | ||
|
|
||
| if not Confirm( | ||
| StrSubstNo( | ||
| ConfirmDeleteQst, | ||
| FieldCaption("Qty. Picked"), | ||
| "Qty. Picked", | ||
| 'Qty. Posted', | ||
| ("Expected Qty. (Base)" - "Remaining Qty. (Base)"), | ||
| TableCaption), | ||
| false) | ||
| then | ||
| Error(''); | ||
| end; | ||
| if ("Expected Qty. (Base)" - "Remaining Qty. (Base)") < "Qty. Picked (Base)" then | ||
| Error(CannotDeleteWithPickedQtyErr); | ||
| end; | ||
|
|
||
| procedure SuspendDeletionCheck(Suspend: Boolean) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1087,6 +1087,9 @@ table 5406 "Prod. Order Line" | |||||||||||||||||||||||||||||||
| Error( | ||||||||||||||||||||||||||||||||
| Text99000000, | ||||||||||||||||||||||||||||||||
| TableCaption, "Line No.", PurchLine.TableCaption()); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if not CalledFromHeader then | ||||||||||||||||||||||||||||||||
| CheckPickedQtyBeforeDeletion() | ||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ProdOrderLineReserve.DeleteLine(Rec); | ||||||||||||||||||||||||||||||||
|
|
@@ -1831,6 +1834,19 @@ table 5406 "Prod. Order Line" | |||||||||||||||||||||||||||||||
| CalledFromHeader := Suspend; | ||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| local procedure CheckPickedQtyBeforeDeletion() | ||||||||||||||||||||||||||||||||
| var | ||||||||||||||||||||||||||||||||
| ProdOrderComponent: Record "Prod. Order Component"; | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| ProdOrderComponent.SetRange(Status, Status); | ||||||||||||||||||||||||||||||||
| ProdOrderComponent.SetRange("Prod. Order No.", "Prod. Order No."); | ||||||||||||||||||||||||||||||||
| ProdOrderComponent.SetRange("Prod. Order Line No.", "Line No."); | ||||||||||||||||||||||||||||||||
| if ProdOrderComponent.FindSet() then | ||||||||||||||||||||||||||||||||
| repeat | ||||||||||||||||||||||||||||||||
| ProdOrderComponent.CheckPickedQtyBeforeDeletion(); | ||||||||||||||||||||||||||||||||
| until ProdOrderComponent.Next() = 0; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1841
to
+1847
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The production-order-line deletion scan loops over every component on the line even though only components with picked quantity can fail the new check. Filter "Qty. Picked (Base)" before FindSet() so the loop only evaluates rows that can actually block deletion.
Suggested change
Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6 |
||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| procedure GetRemainingPutAwayQty(): Decimal | ||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||
| Rec.CalcFields("Put-away Qty. (Base)"); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -766,7 +766,7 @@ table 5405 "Production Order" | |
| end; | ||
|
|
||
| if Status = Status::Released then | ||
| ConfirmDeletion(); | ||
| CheckPickedQtyBeforeDeletion(); | ||
|
|
||
| if Status = Status::Finished then | ||
| DeleteFinishedProdOrderRelations() | ||
|
|
@@ -868,7 +868,6 @@ table 5405 "Production Order" | |
| Text010: Label 'You may have changed a dimension.\\Do you want to update the lines?'; | ||
| Text011: Label 'You cannot change Finished Production Order dimensions.'; | ||
| #pragma warning restore AA0074 | ||
| ConfirmDeleteQst: Label 'The items have been picked. If you delete the Production Order, then the items will remain in the operation area until you put them away.\Related item tracking information that is defined during the pick will be deleted.\Are you sure that you want to delete the Production Order?'; | ||
|
|
||
| protected var | ||
| HideValidationDialog: Boolean; | ||
|
|
@@ -1647,20 +1646,16 @@ table 5405 "Production Order" | |
| RemQtyBaseInvtItemProdOrdComp.Close(); | ||
| end; | ||
|
|
||
| local procedure ConfirmDeletion() | ||
| local procedure CheckPickedQtyBeforeDeletion() | ||
| var | ||
| ProdOrderComponent: Record "Prod. Order Component"; | ||
| Confirmed: Boolean; | ||
| begin | ||
| ProdOrderComponent.SetRange(Status, Rec.Status); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The production-order deletion scan iterates every component for the order even though components with zero picked quantity can be excluded up front. Add a SetFilter("Qty. Picked (Base)", '>%1', 0) before FindSet() so rows that cannot trigger CheckPickedQtyBeforeDeletion() never cross the AL loop. Suggested fix (apply manually — could not be anchored as a one-click suggestion): ProdOrderComponent.SetRange(Status, Rec.Status);
ProdOrderComponent.SetRange("Prod. Order No.", "No.");
ProdOrderComponent.SetFilter("Qty. Picked (Base)", '>%1', 0);
if ProdOrderComponent.FindSet() then
repeat
ProdOrderComponent.CheckPickedQtyBeforeDeletion();
until ProdOrderComponent.Next() = 0;Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6 |
||
| ProdOrderComponent.SetRange("Prod. Order No.", "No."); | ||
| if ProdOrderComponent.FindSet() then | ||
| repeat | ||
| if (ProdOrderComponent."Expected Quantity" - ProdOrderComponent."Remaining Quantity") < ProdOrderComponent."Qty. Picked" then begin | ||
| if not Confirm(ConfirmDeleteQst) then | ||
| Error(''); | ||
| Confirmed := true; | ||
| end; | ||
| until (ProdOrderComponent.Next() = 0) or Confirmed; | ||
| ProdOrderComponent.CheckPickedQtyBeforeDeletion(); | ||
| until ProdOrderComponent.Next() = 0; | ||
| end; | ||
|
|
||
| local procedure ValidateWarehousePutAwayLocation(ProductionOrder: Record "Production Order") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The replacement error for picked-quantity deletion is hard-coded to "You cannot delete the production order..." even though this path is deleting a Prod. Order Component record. That gives the user the wrong operation name in the error dialog. Use component-specific text here, or parameterize the helper so the message can reflect the record actually being deleted.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6