This is an automated email from the ASF dual-hosted git repository. mridulpathak pushed a commit to branch release24.09 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 038d6575bab603d431726553c725ed21e9a6fa33 Author: Mridul Pathak <[email protected]> AuthorDate: Mon Oct 26 13:47:00 2026 +0530 Fix internal callers and a test fixture broken by the new createRequirement permission check - ProductionRunTests#testCreateProductionRunForRequirement calls createRequirement as TestSupplyAdmin, whose SUPPLYADMIN test security group lacked ORDERMGR_CREATE; added it, matching the group's stated scope of executing requirement-based manufacturing tasks - ProposedOrder.java (MRP) now runs its internal createRequirement call as the system user, since auto-generating a requirement during an MRP run is a trusted side effect, not an action on behalf of a specific user - workeffort/servicedef/secas.xml: createWorkEffortRequestItem and createWorkRequirementFulfillment now run their createCustRequestItem/createRequirement ECA actions as the system user --- .../java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java | 7 ++++++- applications/manufacturing/testdef/data/ManufacturingTestsData.xml | 1 + applications/workeffort/servicedef/secas.xml | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java index bf1ceab2ca..69fe65e23a 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java @@ -33,6 +33,7 @@ import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; import org.apache.ofbiz.manufacturing.bom.BOMNode; import org.apache.ofbiz.manufacturing.bom.BOMTree; @@ -265,6 +266,10 @@ public class ProposedOrder { parameters.put("description", "Automatically generated by MRP"); } try { + // createRequirement requires ORDERMGR_CREATE; run as the "system" user since this is a trusted side effect of + // an already-permitted MRP run, not an action taken on behalf of the caller + parameters.put("userLogin", EntityQuery.use(delegator).from("UserLogin") + .where("userLoginId", "system").cache().queryOne()); Map<String, Object> result = dispatcher.runSync("createRequirement", parameters); if (ServiceUtil.isError(result)) { String errorMessage = ServiceUtil.getErrorMessage(result); @@ -272,7 +277,7 @@ public class ProposedOrder { return null; } return (String) result.get("requirementId"); - } catch (GenericServiceException e) { + } catch (GenericServiceException | GenericEntityException e) { Debug.logError(e, "Error : createRequirement with parameters = " + parameters + "--" + e.getMessage(), MODULE); return null; } diff --git a/applications/manufacturing/testdef/data/ManufacturingTestsData.xml b/applications/manufacturing/testdef/data/ManufacturingTestsData.xml index 97be258d37..1ae3dfd68e 100644 --- a/applications/manufacturing/testdef/data/ManufacturingTestsData.xml +++ b/applications/manufacturing/testdef/data/ManufacturingTestsData.xml @@ -41,6 +41,7 @@ under the License. <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPPLYADMIN" permissionId="WORKEFFORTMGR_CREATE"/> <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPPLYADMIN" permissionId="WORKEFFORTMGR_UPDATE"/> <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPPLYADMIN" permissionId="ACCOUNTING_CREATE"/> + <SecurityGroupPermission fromDate="2001-05-13 12:00:00.0" groupId="SUPPLYADMIN" permissionId="ORDERMGR_CREATE"/> <Party partyId="TestSupplyAdmin" partyTypeId="PERSON"/> <Person partyId="TestSupplyAdmin" firstName="Supply" lastName="Admin"/> <UserLogin partyId="TestSupplyAdmin" userLoginId="TestSupplyAdmin"/> diff --git a/applications/workeffort/servicedef/secas.xml b/applications/workeffort/servicedef/secas.xml index 80e08c3fcb..b9a2281267 100644 --- a/applications/workeffort/servicedef/secas.xml +++ b/applications/workeffort/servicedef/secas.xml @@ -52,7 +52,7 @@ under the License. </eca> <eca service="createWorkEffortRequestItem" event="invoke"> <condition field-name="custRequestItemExists" operator="is-empty"/> - <action service="createCustRequestItem" mode="sync"/> + <action service="createCustRequestItem" mode="sync" run-as-user="system"/> </eca> <eca service="createWorkEffortQuote" event="invoke"> <condition field-name="quoteId" operator="is-empty"/> @@ -60,7 +60,7 @@ under the License. </eca> <eca service="createWorkRequirementFulfillment" event="invoke"> <condition field-name="requirementId" operator="is-empty"/> - <action service="createRequirement" mode="sync"/> + <action service="createRequirement" mode="sync" run-as-user="system"/> </eca> <eca service="createShoppingListWorkEffort" event="invoke"> <condition field-name="shoppingListId" operator="is-empty"/>

