diff --git a/src/Apps/W1/Quality Management/app/src/Setup/QltyManagementSetup.Table.al b/src/Apps/W1/Quality Management/app/src/Setup/QltyManagementSetup.Table.al index 483b169469..3a5c247b53 100644 --- a/src/Apps/W1/Quality Management/app/src/Setup/QltyManagementSetup.Table.al +++ b/src/Apps/W1/Quality Management/app/src/Setup/QltyManagementSetup.Table.al @@ -44,6 +44,7 @@ table 20400 "Qlty. Management Setup" { Caption = 'Inspection Creation Option'; ToolTip = 'Specifies whether and how a new quality inspection is created if existing inspections are found.'; + InitValue = "Use existing open inspection if available"; } field(5; "Inspection Search Criteria"; Enum "Qlty. Inspect. Search Criteria") { diff --git a/src/Apps/W1/Quality Management/test/src/QltyTestsProdIntegr.Codeunit.al b/src/Apps/W1/Quality Management/test/src/QltyTestsProdIntegr.Codeunit.al index f1a1f5466c..1fe54e69d0 100644 --- a/src/Apps/W1/Quality Management/test/src/QltyTestsProdIntegr.Codeunit.al +++ b/src/Apps/W1/Quality Management/test/src/QltyTestsProdIntegr.Codeunit.al @@ -31,6 +31,7 @@ codeunit 139966 "Qlty. Tests - Prod. Integr." var ReUsedProdOrderLine: Record "Prod. Order Line"; LibraryAssert: Codeunit "Library Assert"; + LibrarySetupStorage: Codeunit "Library - Setup Storage"; QltyInspectionUtility: Codeunit "Qlty. Inspection Utility"; GenQltyProdOrderGenerator: Codeunit "Qlty. Prod. Order Generator"; LibraryInventory: Codeunit "Library - Inventory"; @@ -2070,6 +2071,7 @@ codeunit 139966 "Qlty. Tests - Prod. Integr." Item: Record Item; ProdProductionOrder: Record "Production Order"; ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + QltyManagementSetup: Record "Qlty. Management Setup"; BeforeCount: Integer; CountOfRoutingLines: Integer; begin @@ -2078,6 +2080,10 @@ codeunit 139966 "Qlty. Tests - Prod. Integr." // [GIVEN] Quality management setup exists QltyInspectionUtility.EnsureSetupExists(); + LibrarySetupStorage.Save(Database::"Qlty. Management Setup"); + QltyManagementSetup.Get(); + QltyManagementSetup."Inspection Creation Option" := QltyManagementSetup."Inspection Creation Option"::"Always create new inspection"; + QltyManagementSetup.Modify(); // [GIVEN] A quality inspection template is created with 3 lines QltyInspectionUtility.CreateTemplate(QltyInspectionTemplateHdr, 3); @@ -2107,6 +2113,8 @@ codeunit 139966 "Qlty. Tests - Prod. Integr." // [THEN] Inspections are created for each routing line LibraryAssert.AreEqual(BeforeCount + CountOfRoutingLines, QltyInspectionHeader.Count(), 'Inspection(s) was not created.'); + + LibrarySetupStorage.Restore(); end; [Test] diff --git a/src/Apps/W1/Quality Management/test/src/QltyTestsReceivingInteg.Codeunit.al b/src/Apps/W1/Quality Management/test/src/QltyTestsReceivingInteg.Codeunit.al index c88650b599..e2d16f39e7 100644 --- a/src/Apps/W1/Quality Management/test/src/QltyTestsReceivingInteg.Codeunit.al +++ b/src/Apps/W1/Quality Management/test/src/QltyTestsReceivingInteg.Codeunit.al @@ -35,6 +35,7 @@ codeunit 139958 "Qlty. Tests - Receiving Integ." LibraryAssert: Codeunit "Library Assert"; LibraryERMCountryData: Codeunit "Library - ERM Country Data"; QltyInspectionUtility: Codeunit "Qlty. Inspection Utility"; + LibrarySetupStorage: Codeunit "Library - Setup Storage"; IsInitialized: Boolean; [Test] @@ -1332,6 +1333,7 @@ codeunit 139958 "Qlty. Tests - Receiving Integ." QltyInspectionTemplateHdr: Record "Qlty. Inspection Template Hdr."; QltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule"; QltyInspectionHeader: Record "Qlty. Inspection Header"; + QltyManagementSetup: Record "Qlty. Management Setup"; Item: Record Item; Vendor: Record Vendor; PurOrderPurchaseHeader: Record "Purchase Header"; @@ -1349,6 +1351,11 @@ codeunit 139958 "Qlty. Tests - Receiving Integ." Initialize(); LibraryWarehouse.CreateLocationWMS(Location, false, false, false, false, false); QltyInspectionUtility.EnsureSetupExists(); + LibrarySetupStorage.Save(Database::"Qlty. Management Setup"); + QltyManagementSetup.Get(); + QltyManagementSetup."Inspection Creation Option" := QltyManagementSetup."Inspection Creation Option"::"Always create new inspection"; + QltyManagementSetup.Modify(); + QltyInspectionUtility.CreateTemplate(QltyInspectionTemplateHdr, 3); QltyInspectionGenRule.DeleteAll(); QltyInspectionUtility.CreatePrioritizedRule(QltyInspectionTemplateHdr, Database::"Purchase Line", QltyInspectionGenRule); @@ -1387,6 +1394,8 @@ codeunit 139958 "Qlty. Tests - Receiving Integ." LibraryAssert.AreEqual(QltyInspectionTemplateHdr.Code, QltyInspectionHeader."Template Code", 'Template code should match provided template'); LibraryAssert.AreEqual(50, QltyInspectionHeader."Source Quantity (Base)", 'Inspection quantity(base) should match reservation entry quantity, not qty. to receive.'); until QltyInspectionHeader.Next() = 0; + + LibrarySetupStorage.Restore(); end; [Test]