You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2020/05/29 14:30:25 UTC
[ofbiz-framework] 02/03: Fixed: Convert InventoryIssueServices.xml
mini lang to groovy (OFBIZ-11591)
This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit b862632a9496b9d0c64ec2f5a3f410e178709bf0
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Fri May 29 16:27:43 2020 +0200
Fixed: Convert InventoryIssueServices.xml mini lang to groovy
(OFBIZ-11591)
Side effect: Inventory Issuance use generic shipment service to control the authorization
but without a shipment, checkCanChangeShipmentStatusGeneral failed with NPE.
I complete the function to escape if a shipment isn't present and only valid with facility permission
---
.../shipment/shipment/ShipmentServices.groovy | 34 ++++++++++++----------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/applications/product/groovyScripts/shipment/shipment/ShipmentServices.groovy b/applications/product/groovyScripts/shipment/shipment/ShipmentServices.groovy
index 1940f59..c51ffe6 100644
--- a/applications/product/groovyScripts/shipment/shipment/ShipmentServices.groovy
+++ b/applications/product/groovyScripts/shipment/shipment/ShipmentServices.groovy
@@ -746,22 +746,24 @@ def checkCanChangeShipmentStatusGeneral(Map inputParameters) {
}
Boolean hasPermission = serviceResult.hasPermission
GenericValue testShipment = from("Shipment").where(inputParameters).cache().queryOne()
-
- boolean badMoveToPacked = testShipment.statusId == "SHIPMENT_PACKED" && fromStatusId == "SHIPMENT_PACKED"
- boolean badMoveToShipped = testShipment.statusId == "SHIPMENT_SHIPPED" &&
- ["SHIPMENT_PACKED", "SHIPMENT_SHIPPED"].contains(fromStatusId)
- boolean badMoveToDelivered = testShipment.statusId == "SHIPMENT_DELIVERED" &&
- ["SHIPMENT_PACKED", "SHIPMENT_SHIPPED", "SHIPMENT_DELIVERED"].contains(fromStatusId)
-
- if (badMoveToPacked || badMoveToShipped || badMoveToDelivered
- || testShipment.statusId == "SHIPMENT_CANCELLED") {
- GenericValue testShipmentStatus = testShipment.getRelatedOne("StatusItem", true)
- Map testShipmentMap = [testShipment: testShipment,
- testShipmentStatus: testShipmentStatus]
- String failMessage = UtilProperties.getMessage("ProductErrorUiLabels",
- "ShipmentCanChangeStatusPermissionError", testShipmentMap, locale)
- hasPermission = false
- result.failMessage = failMessage
+ if (testShipment) {
+
+ boolean badMoveToPacked = testShipment.statusId == "SHIPMENT_PACKED" && fromStatusId == "SHIPMENT_PACKED"
+ boolean badMoveToShipped = testShipment.statusId == "SHIPMENT_SHIPPED" &&
+ ["SHIPMENT_PACKED", "SHIPMENT_SHIPPED"].contains(fromStatusId)
+ boolean badMoveToDelivered = testShipment.statusId == "SHIPMENT_DELIVERED" &&
+ ["SHIPMENT_PACKED", "SHIPMENT_SHIPPED", "SHIPMENT_DELIVERED"].contains(fromStatusId)
+
+ if (badMoveToPacked || badMoveToShipped || badMoveToDelivered
+ || testShipment.statusId == "SHIPMENT_CANCELLED") {
+ GenericValue testShipmentStatus = testShipment.getRelatedOne("StatusItem", true)
+ Map testShipmentMap = [testShipment : testShipment,
+ testShipmentStatus: testShipmentStatus]
+ String failMessage = UtilProperties.getMessage("ProductErrorUiLabels",
+ "ShipmentCanChangeStatusPermissionError", testShipmentMap, locale)
+ hasPermission = false
+ result.failMessage = failMessage
+ }
}
result.hasPermission = hasPermission
return result