Author: jleroux
Date: Sun Oct 23 17:05:59 2011 New Revision: 1187933 URL: http://svn.apache.org/viewvc?rev=1187933&view=rev Log: A patch from Kiran Gawde "Warnings while approving the purchase order" https://issues.apache.org/jira/browse/OFBIZ-4495 Following warnings were noticed in the log while approving the purchase order that was created automatically for drop ship product. [ OrderServices.java:2389:WARN ] Tried to setOrderStatus with the same statusId [ ORDER_APPROVED ] for order with ID [ServiceEcaCondition.java:156:WARN ] From Field (orderTypeId) is not found in context for changeOrderStatus, defaulting to null. The first warning suggest that there is order status is changed again. Shouldn't have happened. The order header should be updated before updating the order items. The second warning happens because some time, changeOrderStatus returns without adding orderTypeId to success result. Since there are secas rules based upon this field, the field should be mandatory and not optional. Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1187933&r1=1187932&r2=1187933&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun Oct 23 17:05:59 2011 @@ -2347,31 +2347,6 @@ public class OrderServices { "OrderYouDoNotHavePermissionToChangeThisOrdersStatus",locale)); } - if ("Y".equals(context.get("setItemStatus"))) { - String newItemStatusId = null; - if ("ORDER_APPROVED".equals(statusId)) { - newItemStatusId = "ITEM_APPROVED"; - } else if ("ORDER_COMPLETED".equals(statusId)) { - newItemStatusId = "ITEM_COMPLETED"; - } else if ("ORDER_CANCELLED".equals(statusId)) { - newItemStatusId = "ITEM_CANCELLED"; - } - - if (newItemStatusId != null) { - try { - Map<String, Object> resp = dispatcher.runSync("changeOrderItemStatus", UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newItemStatusId, "userLogin", userLogin)); - if (ServiceUtil.isError(resp)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, - "OrderErrorCouldNotChangeItemStatus", locale) + newItemStatusId, null, null, resp); - } - } catch (GenericServiceException e) { - Debug.logError(e, "Error changing item status to " + newItemStatusId + ": " + e.toString(), module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, - "OrderErrorCouldNotChangeItemStatus", locale) + newItemStatusId + ": " + e.toString()); - } - } - } - try { GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); @@ -2381,6 +2356,7 @@ public class OrderServices { } // first save off the old status successResult.put("oldStatusId", orderHeader.get("statusId")); + successResult.put("orderTypeId", orderHeader.get("orderTypeId")); if (Debug.verboseOn()) Debug.logVerbose("[OrderServices.setOrderStatus] : From Status : " + orderHeader.getString("statusId"), module); if (Debug.verboseOn()) Debug.logVerbose("[OrderServices.setOrderStatus] : To Status : " + statusId, module); @@ -2418,7 +2394,6 @@ public class OrderServices { successResult.put("needsInventoryIssuance", orderHeader.get("needsInventoryIssuance")); successResult.put("grandTotal", orderHeader.get("grandTotal")); - successResult.put("orderTypeId", orderHeader.get("orderTypeId")); //Debug.logInfo("For setOrderStatus orderHeader is " + orderHeader, module); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -2435,6 +2410,31 @@ public class OrderServices { } } + if ("Y".equals(context.get("setItemStatus"))) { + String newItemStatusId = null; + if ("ORDER_APPROVED".equals(statusId)) { + newItemStatusId = "ITEM_APPROVED"; + } else if ("ORDER_COMPLETED".equals(statusId)) { + newItemStatusId = "ITEM_COMPLETED"; + } else if ("ORDER_CANCELLED".equals(statusId)) { + newItemStatusId = "ITEM_CANCELLED"; + } + + if (newItemStatusId != null) { + try { + Map<String, Object> resp = dispatcher.runSync("changeOrderItemStatus", UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newItemStatusId, "userLogin", userLogin)); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, + "OrderErrorCouldNotChangeItemStatus", locale) + newItemStatusId, null, null, resp); + } + } catch (GenericServiceException e) { + Debug.logError(e, "Error changing item status to " + newItemStatusId + ": " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, + "OrderErrorCouldNotChangeItemStatus", locale) + newItemStatusId + ": " + e.toString()); + } + } + } + successResult.put("orderStatusId", statusId); //Debug.logInfo("For setOrderStatus successResult is " + successResult, module); return successResult; |
Free forum by Nabble | Edit this page |