fixes issue 26345: the warehouse does not fit with the organization
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 15 May 2014 16:55:54 +0200
changeset 23046 74fe7fe43d4b
parent 23045 d2ca6baa9774
child 23047 649d0b7eba54
fixes issue 26345: the warehouse does not fit with the organization
in the Sales Order window
src-db/database/sourcedata/AD_COLUMN.xml
src/org/openbravo/erpCommon/ad_callouts/SE_Order_Organization.java
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu May 15 15:33:57 2014 +0000
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Thu May 15 16:55:54 2014 +0200
@@ -30455,8 +30455,6 @@
 <!--2202-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
 <!--2202-->  <AD_REFERENCE_VALUE_ID><![CDATA[263693E51C7847BF90C897ADB830E2BB]]></AD_REFERENCE_VALUE_ID>
 <!--2202-->  <FIELDLENGTH><![CDATA[22]]></FIELDLENGTH>
-<!--2202-->  <DEFAULTVALUE><![CDATA[@SQL=select m_warehouse_id from ad_org_warehouse ow where ad_org_id = @ad_org_id@ and (select isactive from m_warehouse where m_warehouse_id=ow.m_warehouse_id)='Y' group by m_warehouse_id, priority having min(priority) = priority
-]]></DEFAULTVALUE>
 <!--2202-->  <ISKEY><![CDATA[N]]></ISKEY>
 <!--2202-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--2202-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Order_Organization.java	Thu May 15 15:33:57 2014 +0000
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Order_Organization.java	Thu May 15 16:55:54 2014 +0200
@@ -25,7 +25,10 @@
 import org.openbravo.base.filter.IsIDFilter;
 import org.openbravo.base.filter.RequestFilter;
 import org.openbravo.base.filter.ValueListFilter;
+import org.openbravo.data.FieldProvider;
 import org.openbravo.erpCommon.utility.CashVATUtil;
+import org.openbravo.erpCommon.utility.ComboTableData;
+import org.openbravo.erpCommon.utility.Utility;
 
 public class SE_Order_Organization extends SimpleCallout {
   private static final long serialVersionUID = 1L;
@@ -34,6 +37,9 @@
   @Override
   protected void execute(CalloutInfo info) throws ServletException {
     final String strinpissotrx = info.getStringParameter("inpissotrx", filterYesNo);
+    String strMWarehouseId = info.vars.getStringParameter("inpmWarehouseId");
+    boolean updateWarehouse = true;
+    FieldProvider[] td = null;
 
     // Sales flow only (from the organization)
     if (StringUtils.equals("Y", strinpissotrx)) {
@@ -44,5 +50,31 @@
       }
     }
 
+    try {
+      ComboTableData comboTableData = new ComboTableData(info.vars, this, "TABLE",
+          "M_Warehouse_ID", "197", "C4053C0CD3DC420A9924F24FC1F860A0", Utility.getReferenceableOrg(
+              info.vars, info.vars.getStringParameter("inpadOrgId")), Utility.getContext(this,
+              info.vars, "#User_Client", info.getWindowId()), 0);
+      Utility.fillSQLParameters(this, info.vars, null, comboTableData, info.getWindowId(), "");
+      td = comboTableData.select(false);
+      comboTableData = null;
+    } catch (Exception ex) {
+      throw new ServletException(ex);
+    }
+
+    if (td != null && td.length > 0) {
+      for (int i = 0; i < td.length; i++) {
+        if (td[i].getField("id").equals(strMWarehouseId)) {
+          updateWarehouse = false;
+          break;
+        }
+      }
+      if (updateWarehouse) {
+        info.addResult("inpmWarehouseId", td[0].getField("id"));
+      }
+    } else {
+      info.addResult("inpmWarehouseId", null);
+    }
+
   }
 }