[ 
https://issues.apache.org/jira/browse/OFBIZ-13270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacques Le Roux reopened OFBIZ-13270:
-------------------------------------

Hi Jacopo,

I reopen because there is an issue with productionruntests in trunk and 24.09. 
Here is trunk
in BB: [https://ci2.apache.org/#/builders/49/builds/1191]

I initially found a sole issue with ProductionRunFromRequirement:

{noformat}
2025-06-25 09:32:07,062 |main                 |TestRunContainer              
|I| [JUNIT] : production-run-tests.testCreateProductionRunForRequirement 
starting...
2025-06-25 09:32:07,108 |main                 |SequenceUtil                  
|W| Lock failed; no sequence row was found, will try to add a new one for 
sequence: Requirement
2025-06-25 09:32:07,115 |main                 |SequenceUtil                  
|I| Got bank of sequenced IDs for [Requirement]; curSeqId=10000, 
maxSeqId=10010, bankSize=10
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|I| From Field (statusId) is not found in context for createRequirement, 
defaulting to null.
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|W| doRealCompare returned null, returning false
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|I| From Field (custRequestId) is not found in context for createRequirement, 
defaulting to null.
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|W| doRealCompare returned null, returning false
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|I| From Field (statusId) is not found in context for createRequirement, 
defaulting to null.
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|W| doRealCompare returned null, returning false
2025-06-25 09:32:07,120 |main                 |ServiceEcaCondition           
|W| doRealCompare returned null, returning false
2025-06-25 09:32:07,120 |main                 |ServiceDispatcher             
|T| Sync service [test-dispatcher-Yz7MiZRR59/createRequirement] finished in 
[28] milliseconds
2025-06-25 09:32:07,130 |main                 |ServiceEcaRule                
|I| Running Service ECA Service: createProductionRunFromRequirement, triggered 
by rule on Service: updateRequirement
2025-06-25 09:32:07,134 |main                 |ServiceDispatcher             
|E| Incoming context (in runSync : createProductionRun) does not match expected 
requirements
org.apache.ofbiz.service.ServiceValidationException: The following required 
parameter is missing: pRQuantity
{noformat}
 
{noformat}
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| [JUNIT] Pass: false | # Tests: 35 | # Failed: 1 # Errors: 0
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| [JUNIT] ----------------------------- ERRORS ----------------------------- 
[JUNIT]
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| None
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| [JUNIT] ------------------------------------------------------------------ 
[JUNIT]
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| [JUNIT] ---------------------------- FAILURES ---------------------------- 
[JUNIT]
2025-06-25 09:32:13,673 |main                 |TestRunContainer              
|I| --> 
production-run-tests.testCreateProductionRunForRequirement(org.apache.ofbiz.testtools.SimpleMethodTest):
 Exception thrown while performing entity find: Error doing find by condition: 
org.apache.ofbiz.entity.transaction.GenericTransactionException: The current 
transaction is marked for rollback, not beginning a new transaction and 
aborting current operation; the rollbackOnly was caused by: Service 
[createProductionRun] threw an unexpected 
exception/errororg.apache.ofbiz.service.ServiceValidationException: The 
following required parameter is missing: pRQuantity (The following required 
parameter is missing: pRQuantity) (The current transaction is marked for 
rollback, not beginning a new transaction and aborting current operation; the 
rollbackOnly was caused by: Service [createProductionRun] threw an unexpected 
exception/errororg.apache.ofbiz.service.ServiceValidationException: The 
following required parameter is missing: pRQuantity (The following required 
parameter is missing: pRQuantity))
2025-06-25 09:32:13,675 |main                 |TestRunContainer              
|I| junit.framework.AssertionFailedError: Exception thrown while performing 
entity find: Error doing find by condition: 
org.apache.ofbiz.entity.transaction.GenericTransactionException: The current 
transaction is marked for rollback, not beginning a new transaction and 
aborting current operation; the rollbackOnly was caused by: Service 
[createProductionRun] threw an unexpected 
exception/errororg.apache.ofbiz.service.ServiceValidationException: The 
following required parameter is missing: pRQuantity (The following required 
parameter is missing: pRQuantity) (The current transaction is marked for 
rollback, not beginning a new transaction and aborting current operation; the 
rollbackOnly was caused by: Service [createProductionRun] threw an unexpected 
exception/errororg.apache.ofbiz.service.ServiceValidationException: The 
following required parameter is missing: pRQuantity (The following required 
parameter is missing: pRQuantity))
{noformat}
 

I tried this:

{noformat}
 applications/manufacturing/minilang/test/ProductionRunTests.xml | 1 +
 1 file changed, 1 insertion(+)
diff --git a/applications/manufacturing/minilang/test/ProductionRunTests.xml 
b/applications/manufacturing/minilang/test/ProductionRunTests.xml
index 80290718b5..6f10750ee6 100644
--- a/applications/manufacturing/minilang/test/ProductionRunTests.xml
+++ b/applications/manufacturing/minilang/test/ProductionRunTests.xml
@@ -976,6 +976,7 @@ under the License.
         </entity-one>
         <set field="serviceCtx.userLogin" from-field="userLogin"/>
         <set field="serviceCtx.productId" from-field="productId"/>
+        <set field="serviceCtx.pRQuantity" from-field="quantity"/>
         <set field="serviceCtx.requirementTypeId" 
value="INTERNAL_REQUIREMENT"/>
         <set field="serviceCtx.facilityId" value="WebStoreWarehouse"/>
         <set field="serviceCtx.requirementStartDate" from-field="startDate"/>
 .../apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git 
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
 
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
index 805164ed27..ddf7527aa6 100644
--- 
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
+++ 
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
@@ -2531,7 +2531,9 @@ public class ProductionRunServices {
         Map<String, Object> serviceContext = new HashMap<>();
         serviceContext.clear();
         serviceContext.put("productId", requirement.getString("productId"));
-        serviceContext.put("pRQuantity", quantity);
+        if (quantity == null) {
+            serviceContext.put("pRQuantity", BigDecimal.ZERO;
+        }
         serviceContext.put("startDate", 
requirement.getTimestamp("requirementStartDate"));
         serviceContext.put("facilityId", requirement.getString("facilityId"));
         String workEffortName = null;
{noformat}
 
Then ProductionRunFromRequirement works. But with a long time, not sure it's 
OK. And I got other errors that were not present before:
{code:xml}
This XML file does not appear to have any style information associated with it. 
The document tree is shown below.
<testsuite errors="0" failures="4" hostname="LDLC" name="productionruntests" 
skipped="0" tests="35" time="362.343" timestamp="2025-06-26T14:43:50">
<properties/>
<testcase classname="org.apache.ofbiz.testtools.EntityXmlAssertTest" 
name="manufacturing-tests-data-load" time="0.012"/>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testProductionRunCreation" time="6.392"/>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testProductionRunScheduleConfirm" time="0.584"/>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testProductionRunDateChange" time="0.646"/>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testProductionRunCancelled" time="0.344"/>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testProductionRunQuickIssueAndProduce" time="10.381">
<failure message="Materials Not Available in Warehouse: ID MAT_B_COST - Demo 
Material B for Costing: 1" 
type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError:
 Materials Not Available in Warehouse: ID MAT_B_COST - Demo Material B for 
Costing: 1 at 
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:96) at 
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:90) at 
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:153)
 at 
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:77) 
at 
org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:146)
 at 
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:70)
 at org.apache.ofbiz.base.start.Start.main(Start.java:89) </failure>
</testcase>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testQuickRunProductionRun" time="2.403">
<failure message="Production Run Status Not Changed" 
type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError:
 Production Run Status Not Changed at 
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:96) at 
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:90) at 
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:153)
 at 
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:77) 
at 
org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:146)
 at 
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:70)
 at org.apache.ofbiz.base.start.Start.main(Start.java:89) </failure>
</testcase>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testQuickCloseProductionRun" time="1.746">
<failure message="Production Run Status Not Changed" 
type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError:
 Production Run Status Not Changed at 
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:96) at 
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:90) at 
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:153)
 at 
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:77) 
at 
org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:146)
 at 
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:70)
 at org.apache.ofbiz.base.start.Start.main(Start.java:89) </failure>
</testcase>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testCreateProductionRunForOrder" time="24.875">
<failure message="Production Run Status Not Changed" 
type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError:
 Production Run Status Not Changed at 
org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:96) at 
org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:90) at 
org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:153)
 at 
org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:77) 
at 
org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:146)
 at 
org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:70)
 at org.apache.ofbiz.base.start.Start.main(Start.java:89) </failure>
</testcase>
<testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest" 
name="production-run-tests.testCreateProductionRunForRequirement" 
time="312.811"/>
</testsuite>
{code}

Could you please have a look ? TIA

> Incorrect service call for internal requirement may trigger unnecessary 
> production runs
> ---------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-13270
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13270
>             Project: OFBiz
>          Issue Type: Bug
>          Components: manufacturing
>    Affects Versions: Upcoming Branch, 24.09.01
>            Reporter: Jacopo Cappellato
>            Assignee: Jacopo Cappellato
>            Priority: Major
>             Fix For: Upcoming Branch, 24.09.02
>
>
> When an internal requirement is approved, a production run should be 
> automatically created to fulfill it.
> Currently, the system invokes a special service 
> ({{{}createProductionRunsForProductBom{}}}) instead of the standard one.
> As a result, the system not only creates the production run for the required 
> product, but also additional runs for all its sub-assemblies, even if those 
> sub-assemblies are already available in the warehouse or have existing 
> requirements in the system.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to