details:   https://code.openbravo.com/erp/devel/pi/rev/ad9fcefd23db
changeset: 27291:ad9fcefd23db
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Sun Aug 09 13:15:35 2015 +0530
summary:   Fixes Issue 30470:Wrong posted status for Bill of Materials 
Production
documents

Post Error was shown when a non cost calculated production entry
was posted. Now proper status Cost Not Calculated is shown by raising a
OBException and handling properly it properly in AcctServer.

details:   https://code.openbravo.com/erp/devel/pi/rev/3b3aefef0ce7
changeset: 27292:3b3aefef0ce7
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Mon Aug 10 15:03:57 2015 +0200
summary:   Related to issue 30470: code review improvements

The error message when manually posting the record was overwritten by the 
"@NotCalculatedCost@" string because the catch code always overwrites the 
message set in the correspondent Doc* class.
This was wrong, as the Doc* class should be in charge of setting the error 
message.
Now the message is only overwritten if it hasn't previously set by the 
correspondent Doc* class

diffstat:

 src/org/openbravo/erpCommon/ad_forms/AcctServer.java    |  7 ++++++-
 src/org/openbravo/erpCommon/ad_forms/DocProduction.java |  3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r b8552936f241 -r 3b3aefef0ce7 
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Tue Aug 11 
09:16:33 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Mon Aug 10 
15:03:57 2015 +0200
@@ -1112,11 +1112,16 @@
           "Accounting process failed. RecordID: " + Record_ID + " - TableId: " 
+ AD_Table_ID, e);
       String strMessageError = e.getMessage();
       if (strMessageError.indexOf("") != -1) {
-        setMessageResult(OBMessageUtils.translateError(strMessageError));
+        if (messageResult == null
+            || (messageResult != null && 
StringUtils.isBlank(messageResult.getMessage()))) {
+          setMessageResult(OBMessageUtils.translateError(strMessageError));
+        }
         if ("@NotConvertible@".equals(strMessageError)) {
           return STATUS_NotConvertible;
         } else if (StringUtils.equals(strMessageError, 
"@PeriodNotAvailable@")) {
           return STATUS_PeriodClosed;
+        } else if (StringUtils.equals(strMessageError, "@NotCalculatedCost@")) 
{
+          return STATUS_NotCalculatedCost;
         }
       }
       return STATUS_Error;
diff -r b8552936f241 -r 3b3aefef0ce7 
src/org/openbravo/erpCommon/ad_forms/DocProduction.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocProduction.java   Tue Aug 11 
09:16:33 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocProduction.java   Mon Aug 10 
15:03:57 2015 +0200
@@ -26,6 +26,7 @@
 import javax.servlet.ServletException;
 
 import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.costing.CostingStatus;
 import org.openbravo.dal.core.OBContext;
@@ -193,7 +194,7 @@
           && !line.transaction.isCostCalculated()) {
         Map<String, String> parameters = 
getNotCalculatedCostParameters(line.transaction);
         setMessageResult(conn, STATUS_NotCalculatedCost, "error", parameters);
-        throw new IllegalStateException();
+        throw new OBException("@NotCalculatedCost@");
       }
       String costs = line.getProductCosts(DateAcct, as, conn, con);
       BigDecimal dCosts = new BigDecimal(costs);

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

Reply via email to