Fixed bug 30002: Error in Requisition To Order window
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Tue, 26 May 2015 18:20:34 +0200
changeset 26782 f8b937eb67f2
parent 26780 03456ea1fc63
child 26783 ed79488b19b5
Fixed bug 30002: Error in Requisition To Order window

When creating a purchase order from the Requisition To Order window, an error was raised when lines[i].quantityorder is empty.
Now the SQL query returns quantityorder = 0 when it's null. Then, when inserting the purchase order line, the process inserts "" if quantityorder = 0
src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java
src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Tue May 26 17:30:26 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Tue May 26 18:20:34 2015 +0200
@@ -575,15 +575,30 @@
                 + qtyAux.toString());
 
           try {
-            RequisitionToOrderData.insertCOrderline(conn, this, strCOrderlineID, vars.getClient(),
-                strOrg, vars.getUser(), strCOrderId, Integer.toString(line), strVendor,
-                RequisitionToOrderData.cBPartnerLocationId(this, strVendor), strOrderDate,
-                lines[i].needbydate, lines[i].description, lines[i].mProductId,
-                lines[i].mAttributesetinstanceId, strWarehouse, lines[i].mProductUomId,
-                lines[i].cUomId, quantityOrder.toPlainString(), qtyOrder.toPlainString(),
-                cCurrencyId, lines[i].pricelist, lines[i].priceactual, strPriceListId,
-                lines[i].pricelimit, lines[i].tax, "", lines[i].discount, lines[i].grossUnit,
-                lines[i].grossAmt);
+            RequisitionToOrderData
+                .insertCOrderline(
+                    conn,
+                    this,
+                    strCOrderlineID,
+                    vars.getClient(),
+                    strOrg,
+                    vars.getUser(),
+                    strCOrderId,
+                    Integer.toString(line),
+                    strVendor,
+                    RequisitionToOrderData.cBPartnerLocationId(this, strVendor),
+                    strOrderDate,
+                    lines[i].needbydate,
+                    lines[i].description,
+                    lines[i].mProductId,
+                    lines[i].mAttributesetinstanceId,
+                    strWarehouse,
+                    lines[i].mProductUomId,
+                    lines[i].cUomId,
+                    quantityOrder != null && BigDecimal.ZERO.compareTo(quantityOrder) != 0 ? quantityOrder
+                        .toPlainString() : "", qtyOrder.toPlainString(), cCurrencyId,
+                    lines[i].pricelist, lines[i].priceactual, strPriceListId, lines[i].pricelimit,
+                    lines[i].tax, "", lines[i].discount, lines[i].grossUnit, lines[i].grossAmt);
           } catch (ServletException ex) {
             myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
             releaseRollbackConnection(conn);
--- a/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql	Tue May 26 17:30:26 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql	Tue May 26 18:20:34 2015 +0200
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -145,7 +145,7 @@
     <SqlMethodComment></SqlMethodComment>
     <Sql>
       <![CDATA[
-        SELECT M_REQUISITIONLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE_ID, LOCKQTY, M_REQUISITIONLINE.DESCRIPTION, C_UOM_ID, QUANTITYORDER, M_PRODUCT_UOM_ID,
+        SELECT M_REQUISITIONLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE_ID, LOCKQTY, M_REQUISITIONLINE.DESCRIPTION, C_UOM_ID, COALESCE(QUANTITYORDER, 0) AS QUANTITYORDER, M_PRODUCT_UOM_ID,
           M_REQUISITIONLINE_ID, '' AS C_ORDERLINE_ID,
           COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE) AS PRICELIST,
           COALESCE(M_PRODUCTPRICE.PRICELIMIT, LOCKPRICE) AS PRICELIMIT,