Fixes Issue 25463: Wrong error when posting a purchase invoice
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Tue, 11 Feb 2014 16:30:11 +0530
changeset 22047 b689f78c1ee2
parent 22046 2d05b68d4f4f
child 22048 1433b33bc29c
Fixes Issue 25463: Wrong error when posting a purchase invoice
When there is no conversion between invoice's currency and Product - Purchasing tab currency, wrong error message is shown
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Tue Feb 18 07:58:51 2014 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Tue Feb 11 16:30:11 2014 +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-2013 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2014 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -29,6 +29,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.FieldProvider;
@@ -37,6 +38,7 @@
 import org.openbravo.erpCommon.utility.CashVATUtil;
 import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.SequenceIdData;
+import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.currency.ConversionRateDoc;
 import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.invoice.Invoice;
@@ -1129,6 +1131,11 @@
 
     } catch (ServletException e) {
       log4jDocInvoice.warn(e);
+      if (e.getMessage().contains("@NoConversionRate@")) {
+        setMessageResult(Utility.translateError(conn, RequestContext.get().getVariablesSecureApp(),
+            OBContext.getOBContext().getLanguage().getId(), e.getMessage()));
+        throw new IllegalStateException();
+      }
     }
   } // updateProductInfo