diff --git a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveAutoChoose.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveAutoChoose.Codeunit.al index c887da3c28..dd9a9d649c 100644 --- a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveAutoChoose.Codeunit.al +++ b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveAutoChoose.Codeunit.al @@ -68,6 +68,8 @@ codeunit 20442 "Qlty. Disp. Move Auto Choose" implements "Qlty. Disposition" if (TempQuantityToActQltyDispositionBuffer."New Location Code" <> '') and (TempQuantityToActQltyDispositionBuffer."New Location Code" <> TempQuantityToActQltyDispositionBuffer."Location Filter") then Error(UnableToChangeBinsBetweenLocationsBecauseDirectedPickAndPutErr, QltyInspectionHeader."No.", TempQuantityToActQltyDispositionBuffer."Location Filter", TempQuantityToActQltyDispositionBuffer."New Location Code"); + QltyInventoryAvailability.ErrorIfFromBinIsReceiveBin(QltyInspectionHeader, TempQuantityToActQltyDispositionBuffer.GetFromLocationCode(), TempQuantityToActQltyDispositionBuffer.GetFromBinCode()); + if BackwardsCompatibleFlagCallMoveInventoryFirstUseWorksheet then DidSomething := QltyDispMoveWorksheet.PerformDisposition(QltyInspectionHeader, TempQuantityToActQltyDispositionBuffer) else diff --git a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveWorksheet.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveWorksheet.Codeunit.al index b6fa140745..fbe29537cd 100644 --- a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveWorksheet.Codeunit.al +++ b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyDispMoveWorksheet.Codeunit.al @@ -70,6 +70,8 @@ codeunit 20451 "Qlty. Disp. Move Worksheet" implements "Qlty. Disposition" if (TempQuantityToActQltyDispositionBuffer."New Location Code" <> '') and (TempQuantityToActQltyDispositionBuffer."New Location Code" <> TempQuantityToActQltyDispositionBuffer."Location Filter") then Error(UnableToChangeBinsBetweenLocationsBecauseDirectedPickAndPutErr, QltyInspectionHeader."No.", TempQuantityToActQltyDispositionBuffer."Location Filter", TempQuantityToActQltyDispositionBuffer."New Location Code"); + QltyInventoryAvailability.ErrorIfFromBinIsReceiveBin(QltyInspectionHeader, TempQuantityToActQltyDispositionBuffer.GetFromLocationCode(), TempQuantityToActQltyDispositionBuffer.GetFromBinCode()); + MovementLineCreated := false; CreateWarehouseWorksheetLine( diff --git a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyMoveInventory.Report.al b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyMoveInventory.Report.al index 027155ef26..9b2d6b1ed5 100644 --- a/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyMoveInventory.Report.al +++ b/src/Apps/W1/Quality Management/app/src/Dispositions/Move/QltyMoveInventory.Report.al @@ -250,6 +250,7 @@ report 20404 "Qlty. Move Inventory" Caption = 'Location'; ToolTip = 'Specifies the destination location to move the inventory to.'; ShowMandatory = true; + Editable = IsDestinationLocationEditable; trigger OnValidate() var @@ -258,17 +259,47 @@ report 20404 "Qlty. Move Inventory" ShowBinCode := true; if DestinationLocation.Get(DestinationLocationCode) then ShowBinCode := DestinationLocation."Bin Mandatory"; + DestinationBinCode := ''; end; } field(ChooseDestinationBin; DestinationBinCode) { ApplicationArea = All; - TableRelation = Bin.Code; Caption = 'Bin'; ToolTip = 'Specifies the destination bin to move the inventory to.'; ShowMandatory = true; Enabled = ShowBinCode; + + trigger OnLookup(var Text: Text): Boolean + var + DestinationBin: Record Bin; + BinList: Page "Bin List"; + begin + if DestinationLocationCode = '' then + exit(false); + + DestinationBin.SetRange("Location Code", DestinationLocationCode); + BinList.SetTableView(DestinationBin); + BinList.LookupMode(true); + if BinList.RunModal() = Action::LookupOK then begin + BinList.GetRecord(DestinationBin); + Text := DestinationBin.Code; + exit(true); + end; + exit(false); + end; + + trigger OnValidate() + var + DestinationBin: Record Bin; + begin + if DestinationBinCode = '' then + exit; + if DestinationLocationCode = '' then + exit; + DestinationBin.Get(DestinationLocationCode, DestinationBinCode); + end; } } group(PostImmediately) @@ -300,6 +331,28 @@ report 20404 "Qlty. Move Inventory" } } } + + trigger OnOpenPage() + var + QltyInspectionHeader: Record "Qlty. Inspection Header"; + DestinationLocation: Record Location; + begin + QltyInspectionHeader.CopyFilters(CurrentInspection); + if not QltyInspectionHeader.FindSet() then + exit; + if QltyInspectionHeader.Next() <> 0 then + exit; + + if QltyInspectionHeader."Location Code" = '' then + exit; + + DestinationLocationCode := QltyInspectionHeader."Location Code"; + IsDestinationLocationEditable := false; + + ShowBinCode := false; + if DestinationLocation.Get(DestinationLocationCode) then + ShowBinCode := DestinationLocation."Bin Mandatory"; + end; } var @@ -313,6 +366,7 @@ report 20404 "Qlty. Move Inventory" ShouldPostImmediately: Boolean; ShouldPostLater: Boolean; ShowBinCode: Boolean; + IsDestinationLocationEditable: Boolean; UseMovement: Boolean; UseReclass: Boolean; IsMoveSpecific: Boolean; @@ -327,5 +381,6 @@ report 20404 "Qlty. Move Inventory" ShouldPostLater := not ShouldPostImmediately; UseReclass := not UseMovement; IsMoveSpecific := true; + IsDestinationLocationEditable := true; end; } diff --git a/src/Apps/W1/Quality Management/app/src/Integration/Inventory/QltyInventoryAvailability.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Integration/Inventory/QltyInventoryAvailability.Codeunit.al index ee7b0421c7..e8e13f8888 100644 --- a/src/Apps/W1/Quality Management/app/src/Integration/Inventory/QltyInventoryAvailability.Codeunit.al +++ b/src/Apps/W1/Quality Management/app/src/Integration/Inventory/QltyInventoryAvailability.Codeunit.al @@ -37,6 +37,7 @@ codeunit 20445 "Qlty. Inventory Availability" QtyToReceiveNameLbl: Label 'Qty. to Receive', Locked = true; QtyToHandleBaseNameLbl: Label 'Qty. to Handle (Base)', Locked = true; QuantityToHandleNameLbl: Label 'Quantity to Handle', Locked = true; + CannotMoveFromReceiveBinErr: Label 'The items for inspection %1 are still in the receiving bin %2 at location %3 and cannot be moved yet. Put the items away first by using a Put-Away, and then move the inventory.', Comment = '%1=the inspection, %2=from bin code, %3=from location code'; /// /// GetCurrentLocationOfTrackedInventory gets the current location of the Item+Item tracking defined on the inspection. @@ -456,6 +457,27 @@ codeunit 20445 "Qlty. Inventory Availability" OnAfterPopulateBinContentBuffer(QltyInspectionHeader, TempInstructionQltyDispositionBuffer, TempQuantityQltyDispositionBuffer, TempExistingInventoryBinContent); end; + /// + /// Raises an error if the inventory would be moved from a receiving bin, which is not allowed in directed put-away and pick locations until the items have been put away. + /// + /// The inspection the inventory move relates to. + /// The location code the inventory is being moved from. + /// The bin code the inventory is being moved from. + internal procedure ErrorIfFromBinIsReceiveBin(QltyInspectionHeader: Record "Qlty. Inspection Header"; FromLocationCode: Code[10]; FromBinCode: Code[20]) + var + FromBin: Record Bin; + BinType: Record "Bin Type"; + begin + if (FromLocationCode = '') or (FromBinCode = '') then + exit; + if not FromBin.Get(FromLocationCode, FromBinCode) then + exit; + if not BinType.Get(FromBin."Bin Type Code") then + exit; + if BinType.Receive then + Error(CannotMoveFromReceiveBinErr, QltyInspectionHeader.GetFriendlyIdentifier(), FromBinCode, FromLocationCode); + end; + [IntegrationEvent(false, false)] procedure OnBeforePopulateBinContentBuffer(var QltyInspectionHeader: Record "Qlty. Inspection Header"; var TempInstructionQltyDispositionBuffer: Record "Qlty. Disposition Buffer" temporary; var TempQuantityQltyDispositionBuffer: Record "Qlty. Disposition Buffer" temporary; var TempExistingInventoryBinContent: Record "Bin Content" temporary; var IsHandled: Boolean) begin