Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0032373Openbravo ERP09. Financial managementpublic2016-02-26 13:572016-03-01 18:41
ngarcia 
AtulOpenbravo 
immediateminoralways
closedfixed 
5
 
3.0PR15Q4.53.0PR15Q4.5 
aferraz
Core
Production - Confirmed Stable
2014-09-02
3.0PR14Q4
https://code.openbravo.com/erp/devel/pi/rev/69108bf7103b [^]
No
0032373: NullPointerException when posting a Physical Inventory with a line without an associated transaction (not stocked product)
NullPointerException when posting a Physical Inventory with a line without an associated transaction (not stocked product)
In an instance without the following issue solved:

https://issues.openbravo.com/view.php?id=31835 [^]

As group admin role:
   Create a new product and set is as Stocked = 'Y'
   Create a goods receipt to increase its stock
   Create a goods shipment to leave its stock to 0
   Set it as Stocked = 'N' (it will not possible after the fix of 31835)
   Create a Physical inventory for the same warehouse the stock was received in
   Launch the Create Inventory Count with the option of Inventory Quantity empty
   Check the product is not inserted
   Launch the Create Inventory Count with the option of Inventory Quantity = 0
   Check the product is inserted and it shouldn't
   Process the inventory
   Try to post it and check the following error message is shown:
      Process failed during execution
   The logs shows:
      WARN org.openbravo.erpCommon.ad_forms.AcctServer - Accounting process failed. RecordID: 0E718DFD7B384111B2D2112722FCFF8B - TableId: 321
java.lang.NullPointerException
    at org.openbravo.erpCommon.ad_forms.DocInventory.createFact(DocInventory.java:183)
    at org.openbravo.erpCommon.ad_forms.AcctServer.postLogic(AcctServer.java:1111)
    at org.openbravo.erpCommon.ad_forms.AcctServer.post(AcctServer.java:804)
    at org.openbravo.erpCommon.ad_forms.AcctServer.post(AcctServer.java:719)
    at org.openbravo.erpCommon.ad_actionButton.Posted.processButton(Posted.java:273)
    at org.openbravo.erpCommon.ad_actionButton.Posted.doPost(Posted.java:104)
The problem is in the following code:

      if ("NC".equals(line.transaction.getCostingStatus())) {
        setStatus(STATUS_NotCalculatedCost);
      }

but it will also fail in the following:

      if (line.transaction.getTransactionCost() != null
          && line.transaction.getTransactionCost().compareTo(ZERO) == 0) {
        countInvLinesWithTrnCostZero++;
      }

as line.transaction is null

Apart from that, the Create Inventory Count process should avoid inserting not stocked products (check the solution of the 30697 issue)
No tags attached.
blocks defect 0032364 closed AtulOpenbravo NullPointerException when posting a Physical Inventory with a line without an associated transaction (not stocked product) 
Issue History
2016-02-29 14:01AtulOpenbravoTypedefect => backport
2016-02-29 14:01AtulOpenbravoTarget Version => 3.0PR15Q4.5
2016-02-29 14:44AtulOpenbravoRegression date => 2014-09-02
2016-02-29 14:44AtulOpenbravoRegression introduced in release => 3.0PR14Q4
2016-02-29 14:44AtulOpenbravoRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/69108bf7103b [^]
2016-02-29 14:45AtulOpenbravoNote Added: 0084597
2016-03-01 18:38aferrazRegression level => Production - Confirmed Stable
2016-03-01 18:40hgbotCheckin
2016-03-01 18:40hgbotNote Added: 0084646
2016-03-01 18:40hgbotStatusscheduled => resolved
2016-03-01 18:40hgbotResolutionopen => fixed
2016-03-01 18:40hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR15Q4.5/rev/3b8f11efa3cc10576f47b87b581c309136b2f93a [^]
2016-03-01 18:40hgbotCheckin
2016-03-01 18:40hgbotNote Added: 0084647
2016-03-01 18:41aferrazReview Assigned To => aferraz
2016-03-01 18:41aferrazNote Added: 0084648
2016-03-01 18:41aferrazStatusresolved => closed
2016-03-01 18:41aferrazFixed in Version => 3.0PR15Q4.5

Notes
(0084597)
AtulOpenbravo   
2016-02-29 14:45   
Test Plan
- Login as Group Admin role:
- Create a new product and set is as Stocked = 'Y'
- Create a goods receipt to increase its stock
- Create a goods shipment to leave its stock to 0
- Set it as Stocked = 'N'.
- Create a Physical inventory for the same warehouse the stock was received in.
- Launch the Create Inventory Count with the option of Inventory Quantity empty.
- Check the product is not inserted.
- Launch the Create Inventory Count with the option of Inventory Quantity = 0.
- Check that product is not inserted.
(0084646)
hgbot   
2016-03-01 18:40   
Repository: erp/backports/3.0PR15Q4.5
Changeset: 3b8f11efa3cc10576f47b87b581c309136b2f93a
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Mon Feb 29 17:00:12 2016 +0530
URL: http://code.openbravo.com/erp/backports/3.0PR15Q4.5/rev/3b8f11efa3cc10576f47b87b581c309136b2f93a [^]

Fixes Issue 32373: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.

---
M src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml
M src/org/openbravo/erpCommon/ad_forms/DocInventory.java
---
(0084647)
hgbot   
2016-03-01 18:40   
Repository: erp/backports/3.0PR15Q4.5
Changeset: ca63ad793d7c6d5807299982c7a813250f8f9345
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Tue Mar 01 18:02:57 2016 +0100
URL: http://code.openbravo.com/erp/backports/3.0PR15Q4.5/rev/ca63ad793d7c6d5807299982c7a813250f8f9345 [^]

Related to issue 32373: Code review improvements

Call line.getProductCosts only when line.transaction != null in DocInventory.java.

---
M src/org/openbravo/erpCommon/ad_forms/DocInventory.java
---
(0084648)
aferraz   
2016-03-01 18:41   
Code review OK