details:   https://code.openbravo.com/erp/devel/pi/rev/a590572e37eb
changeset: 33966:a590572e37eb
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Wed May 16 23:01:26 2018 +0530
summary:   Fixes Issue 0038557:Cannot select an orphan line in Return Material
Receipt if product has Alternate UOM defined

While inserting orphan line when uom management is enable, set
return qty as operative qty and uom as operative uom

details:   https://code.openbravo.com/erp/devel/pi/rev/59a5aec24377
changeset: 33967:59a5aec24377
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Wed May 16 17:16:05 2018 +0530
summary:   Fixes Issue 0038558: Cannot add an orphan line in Return
>From Customer window if the role does not have access to
Product window

Use setAdminMode prior to access product object in
insert RM orphan line process.

diffstat:

 src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java |  41 
+++++----
 1 files changed, 24 insertions(+), 17 deletions(-)

diffs (67 lines):

diff -r 7532d72d33fb -r 59a5aec24377 
src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java       
Wed May 16 11:13:21 2018 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java       
Wed May 16 17:16:05 2018 +0530
@@ -33,6 +33,7 @@
 import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.materialmgmt.UOMUtil;
 import org.openbravo.model.common.order.Order;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.order.ReturnReason;
@@ -66,25 +67,26 @@
     final String strTaxId = (String) bundle.getParams().get("cTaxId");
     final String strReturnReason = (String) 
bundle.getParams().get("cReturnReasonId");
 
-    Order order = OBDal.getInstance().get(Order.class, strOrderId);
-    Product product = OBDal.getInstance().get(Product.class, strProductId);
-
-    if (!product.isReturnable()) {
-      throw new OBException("@Product@ '" + product.getIdentifier() + "' 
@ServiceIsNotReturnable@");
-    }
-    AttributeSetInstance attrSetInstance = null;
-    if (strAttributeSetInstanceId != null) {
-      attrSetInstance = OBDal.getInstance().get(AttributeSetInstance.class,
-          strAttributeSetInstanceId);
-    }
-    if (product.getAttributeSet() != null
-        && (strAttributeSetInstanceId == null || 
strAttributeSetInstanceId.equals(""))
-        && (product.getUseAttributeSetValueAs() == null || 
product.getUseAttributeSetValueAs() != "F")) {
-      throw new OBException("@productWithoutAttributeSet@");
-    }
-
     OBContext.setAdminMode(true);
     try {
+      Order order = OBDal.getInstance().get(Order.class, strOrderId);
+      Product product = OBDal.getInstance().get(Product.class, strProductId);
+
+      if (!product.isReturnable()) {
+        throw new OBException("@Product@ '" + product.getIdentifier()
+            + "' @ServiceIsNotReturnable@");
+      }
+      AttributeSetInstance attrSetInstance = null;
+      if (strAttributeSetInstanceId != null) {
+        attrSetInstance = OBDal.getInstance().get(AttributeSetInstance.class,
+            strAttributeSetInstanceId);
+      }
+      if (product.getAttributeSet() != null
+          && (strAttributeSetInstanceId == null || 
strAttributeSetInstanceId.equals(""))
+          && (product.getUseAttributeSetValueAs() == null || 
product.getUseAttributeSetValueAs() != "F")) {
+        throw new OBException("@productWithoutAttributeSet@");
+      }
+
       OrderLine newOrderLine = OBProvider.getInstance().get(OrderLine.class);
       newOrderLine.setSalesOrder(order);
       newOrderLine.setOrganization(order.getOrganization());
@@ -97,6 +99,11 @@
       newOrderLine.setUOM(product.getUOM());
       newOrderLine.setOrderedQuantity(returnedQty.negate());
 
+      if (UOMUtil.isUomManagementEnabled()) {
+        newOrderLine.setOperativeQuantity(returnedQty.negate());
+        newOrderLine.setOperativeUOM(product.getUOM());
+      }
+
       if (strUnitPrice.isEmpty()) {
         ProductPrice productPrice = getProductPrice(product, 
order.getOrderDate(),
             order.isSalesTransaction(), order.getPriceList());

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to