details:   https://code.openbravo.com/erp/devel/pi/rev/9a7c89992e60
changeset: 29982:9a7c89992e60
user:      Mark <markmm82 <at> gmail.com>
date:      Mon Aug 29 13:14:09 2016 -0400
summary:   Fixes issue 32806: Can void a receipt if role doesn't have Client 
window access

Allow to void a goods receipt even the role does not have access to Client 
window. The OB Context is configured as Admin mode to avoid access validations 
when getClientInformationList() method of ADClient class is invoked.

diffstat:

 src/org/openbravo/costing/CostingUtils.java                   |  10 ++++++++++
 src/org/openbravo/erpCommon/ad_actionButton/ProcessGoods.java |   6 +++---
 src/org/openbravo/materialmgmt/InventoryCountProcess.java     |   5 +++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diffs (84 lines):

diff -r 00c493919c46 -r 9a7c89992e60 src/org/openbravo/costing/CostingUtils.java
--- a/src/org/openbravo/costing/CostingUtils.java       Tue Aug 30 23:25:40 
2016 +0530
+++ b/src/org/openbravo/costing/CostingUtils.java       Mon Aug 29 13:14:09 
2016 -0400
@@ -48,6 +48,7 @@
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.financial.FinancialUtils;
+import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.DocumentType;
@@ -772,4 +773,13 @@
     qry.setMaxResults(1);
     return StringUtils.equals(trx.getId(), (String) qry.uniqueResult());
   }
+
+  public static boolean isAllowNegativeStock(Client client) {
+    try {
+      OBContext.setAdminMode(true);
+      return client.getClientInformationList().get(0).isAllowNegativeStock();
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
 }
diff -r 00c493919c46 -r 9a7c89992e60 
src/org/openbravo/erpCommon/ad_actionButton/ProcessGoods.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/ProcessGoods.java     Tue Aug 
30 23:25:40 2016 +0530
+++ b/src/org/openbravo/erpCommon/ad_actionButton/ProcessGoods.java     Mon Aug 
29 13:14:09 2016 -0400
@@ -11,7 +11,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) 2012-2015 Openbravo SLU
+ * All portions are Copyright (C) 2012-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -38,6 +38,7 @@
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.costing.CostingUtils;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.FieldProvider;
@@ -113,8 +114,7 @@
       Client client = OBDal.getInstance().get(Client.class, vars.getClient());
 
       if (StringUtils.equals(strWindowId, Goods_Receipt_Window)
-          && StringUtils.equals(strdocaction, "RC")
-          && !client.getClientInformationList().get(0).isAllowNegativeStock()) 
{
+          && StringUtils.equals(strdocaction, "RC") && 
!CostingUtils.isAllowNegativeStock(client)) {
         List<String> receiptLineIdList = 
getReceiptLinesWithoutStock(receiptId);
         if (!receiptLineIdList.isEmpty()) {
           ShipmentInOut receipt = OBDal.getInstance().get(ShipmentInOut.class, 
receiptId);
diff -r 00c493919c46 -r 9a7c89992e60 
src/org/openbravo/materialmgmt/InventoryCountProcess.java
--- a/src/org/openbravo/materialmgmt/InventoryCountProcess.java Tue Aug 30 
23:25:40 2016 +0530
+++ b/src/org/openbravo/materialmgmt/InventoryCountProcess.java Mon Aug 29 
13:14:09 2016 -0400
@@ -11,7 +11,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) 2012-2015 Openbravo SLU
+ * All portions are Copyright (C) 2012-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -45,6 +45,7 @@
 import org.hibernate.type.StringType;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.base.exception.OBException;
+import org.openbravo.costing.CostingUtils;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.security.OrganizationStructureProvider;
@@ -279,7 +280,7 @@
     // queryInsert.setBoolean("checkReservation", checkReservationQty);
     queryInsert.executeUpdate();
 
-    if 
(!inventory.getClient().getClientInformationList().get(0).isAllowNegativeStock()
+    if (!CostingUtils.isAllowNegativeStock(inventory.getClient())
         && !"C".equals(inventory.getInventoryType()) && 
!"O".equals(inventory.getInventoryType())) {
       checkStock(inventory);
     }

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to