Fixes Issue
32364:NullPointerException when posting a Physical Inventory
with a line without an associated transaction (not stocked product)
- Avoid insertion of zero quantity products in inventory line having
stocked flag as No.
- Code improvement to handle line with null transaction.
--- a/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml Tue Mar 01 13:19:21 2016 +0100
+++ b/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml Mon Feb 29 17:00:12 2016 +0530
@@ -219,6 +219,7 @@
LEFT JOIN m_attributeset aset ON p.m_attributeset_id = aset.m_attributeset_id
WHERE p.AD_Client_ID=v_Client_ID -- only ..
AND p.IsActive='Y'
+ AND p.IsStocked='Y'
AND(v_ProductValue IS NULL
OR UPPER(p.Value) LIKE v_ProductValue)
AND(v_Locator_ID IS NULL
--- a/src/org/openbravo/erpCommon/ad_forms/DocInventory.java Tue Mar 01 13:19:21 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInventory.java Mon Feb 29 17:00:12 2016 +0530
@@ -11,7 +11,7 @@
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2014 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
******************************************************************************
*/
package org.openbravo.erpCommon.ad_forms;
@@ -23,6 +23,7 @@
import javax.servlet.ServletException;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.openbravo.base.secureApp.VariablesSecureApp;
import org.openbravo.costing.CostingStatus;
@@ -180,12 +181,13 @@
int countInvLinesWithTrnCostZero = 0;
for (int i = 0; i < p_lines.length; i++) {
DocLine_Material line = (DocLine_Material) p_lines[i];
- if ("NC".equals(line.transaction.getCostingStatus())) {
+ if (line.transaction != null && "NC".equals(line.transaction.getCostingStatus())) {
setStatus(STATUS_NotCalculatedCost);
}
- if (line.transaction.getTransactionCost() != null
- && line.transaction.getTransactionCost().compareTo(ZERO) == 0) {
+ if (line.transaction == null
+ || (line.transaction.getTransactionCost() != null && line.transaction
+ .getTransactionCost().compareTo(ZERO) == 0)) {
countInvLinesWithTrnCostZero++;
}
}
@@ -210,7 +212,10 @@
}
String costs = line.getProductCosts(DateAcct, as, conn, con);
log4jDocInventory.debug("CreateFact - before DR - Costs: " + costs);
- BigDecimal b_Costs = new BigDecimal(costs);
+ BigDecimal b_Costs = BigDecimal.ZERO;
+ if (costs != null && !StringUtils.isBlank(costs) && !StringUtils.isEmpty(costs)) {
+ b_Costs = new BigDecimal(costs);
+ }
Account assetAccount = line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn);
if (assetAccount == null) {
Product product = OBDal.getInstance().get(Product.class, line.m_M_Product_ID);