Merge stable changesets from int to main
authorRM packaging bot <staff.rm@openbravo.com>
Sat, 23 Jan 2010 12:43:20 +0100
changeset 5998 f6cec48f0f2b
parent 5997 ba83bb4d9240 (current diff)
parent 5966 ff51a1585380 (diff)
child 5999 71fb509c32a4
Merge stable changesets from int to main
src-db/database/sourcedata/AD_MODULE.xml
src-db/database/sourcedata/AD_PROCESS.xml
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -16505,6 +16505,18 @@
 <!--143C42B0268F411F8D6AC8475B8A0ABF-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--143C42B0268F411F8D6AC8475B8A0ABF--></AD_MODEL_OBJECT>
 
+<!--14CF968D43864D6AB6F2CEF1971A785D--><AD_MODEL_OBJECT>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <AD_MODEL_OBJECT_ID><![CDATA[14CF968D43864D6AB6F2CEF1971A785D]]></AD_MODEL_OBJECT_ID>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <ACTION><![CDATA[P]]></ACTION>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_process.ApplyModulesCallServlet]]></CLASSNAME>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <AD_PROCESS_ID><![CDATA[F9DFC02162B0473B9676870117DF61FE]]></AD_PROCESS_ID>
+<!--14CF968D43864D6AB6F2CEF1971A785D-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--14CF968D43864D6AB6F2CEF1971A785D--></AD_MODEL_OBJECT>
+
 <!--166DCDDE740F457792246F2FD3320E62--><AD_MODEL_OBJECT>
 <!--166DCDDE740F457792246F2FD3320E62-->  <AD_MODEL_OBJECT_ID><![CDATA[166DCDDE740F457792246F2FD3320E62]]></AD_MODEL_OBJECT_ID>
 <!--166DCDDE740F457792246F2FD3320E62-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -26850,6 +26850,16 @@
 <!--D1AAB55BF548431B99C1A37F4C9FB5DE-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--D1AAB55BF548431B99C1A37F4C9FB5DE--></AD_MODEL_OBJECT_MAPPING>
 
+<!--D1AF0B8612634671AC315303EEFC8290--><AD_MODEL_OBJECT_MAPPING>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[D1AF0B8612634671AC315303EEFC8290]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <AD_MODEL_OBJECT_ID><![CDATA[14CF968D43864D6AB6F2CEF1971A785D]]></AD_MODEL_OBJECT_ID>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <MAPPINGNAME><![CDATA[/ad_process/ApplyModulesCallServlet.html]]></MAPPINGNAME>
+<!--D1AF0B8612634671AC315303EEFC8290-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--D1AF0B8612634671AC315303EEFC8290--></AD_MODEL_OBJECT_MAPPING>
+
 <!--DF6BD3A8D6814A42A31B029036E3CAD0--><AD_MODEL_OBJECT_MAPPING>
 <!--DF6BD3A8D6814A42A31B029036E3CAD0-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[DF6BD3A8D6814A42A31B029036E3CAD0]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--DF6BD3A8D6814A42A31B029036E3CAD0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODULE.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODULE.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -6,7 +6,7 @@
 <!--0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0-->  <NAME><![CDATA[core]]></NAME>
-<!--0-->  <VERSION><![CDATA[2.50.15961]]></VERSION>
+<!--0-->  <VERSION><![CDATA[2.50.15808]]></VERSION>
 <!--0-->  <DESCRIPTION><![CDATA[Core module is the base one]]></DESCRIPTION>
 <!--0-->  <HELP><![CDATA[Core module is the base one, all developments in core are included as part of the standard Openbravo ERP.]]></HELP>
 <!--0-->  <URL><![CDATA[www.openbravo.com]]></URL>
@@ -21,7 +21,7 @@
 <!--0-->  <HASCHARTOFACCOUNTS><![CDATA[N]]></HASCHARTOFACCOUNTS>
 <!--0-->  <ISTRANSLATIONMODULE><![CDATA[N]]></ISTRANSLATIONMODULE>
 <!--0-->  <HASREFERENCEDATA><![CDATA[Y]]></HASREFERENCEDATA>
-<!--0-->  <VERSION_LABEL><![CDATA[CI]]></VERSION_LABEL>
+<!--0-->  <VERSION_LABEL><![CDATA[dev]]></VERSION_LABEL>
 <!--0-->  <ISCOMMERCIAL><![CDATA[N]]></ISCOMMERCIAL>
 <!--0--></AD_MODULE>
 
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -6048,4 +6048,23 @@
 <!--D85D5B5E368A49B1A6293BA4AE15F0F9-->  <UIPATTERN><![CDATA[S]]></UIPATTERN>
 <!--D85D5B5E368A49B1A6293BA4AE15F0F9--></AD_PROCESS>
 
+<!--F9DFC02162B0473B9676870117DF61FE--><AD_PROCESS>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <AD_PROCESS_ID><![CDATA[F9DFC02162B0473B9676870117DF61FE]]></AD_PROCESS_ID>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <VALUE><![CDATA[ApplyModulesCallServlet]]></VALUE>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <NAME><![CDATA[ApplyModulesCallServlet]]></NAME>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <DESCRIPTION><![CDATA[This process is called by AJAX calls from the main ApplyModules process]]></DESCRIPTION>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ACCESSLEVEL><![CDATA[7]]></ACCESSLEVEL>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISREPORT><![CDATA[N]]></ISREPORT>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--F9DFC02162B0473B9676870117DF61FE-->  <UIPATTERN><![CDATA[M]]></UIPATTERN>
+<!--F9DFC02162B0473B9676870117DF61FE--></AD_PROCESS>
+
 </data>
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -4749,6 +4749,7 @@
 <!--800055-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
 <!--800055-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--800055-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--800055-->  <DEFAULTVALUE><![CDATA[@SQL=SELECT (NOW()+90) as d FROM DUAL]]></DEFAULTVALUE>
 <!--800055-->  <AD_ELEMENT_ID><![CDATA[1581]]></AD_ELEMENT_ID>
 <!--800055--></AD_PROCESS_PARA>
 
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Fri Jan 22 17:02:32 2010 +0100
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Sat Jan 23 12:43:20 2010 +0100
@@ -16713,6 +16713,17 @@
 <!--2F88E56E83B04A9BA4E716417B50DF99-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--2F88E56E83B04A9BA4E716417B50DF99--></AD_TEXTINTERFACES>
 
+<!--357B158A0FE44CB68C910D56888DAD0C--><AD_TEXTINTERFACES>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <AD_TEXTINTERFACES_ID><![CDATA[357B158A0FE44CB68C910D56888DAD0C]]></AD_TEXTINTERFACES_ID>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <TEXT><![CDATA[ to acquire modules.]]></TEXT>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/ad_forms/ModuleManagement_ErrorCommercial.html]]></FILENAME>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--357B158A0FE44CB68C910D56888DAD0C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--357B158A0FE44CB68C910D56888DAD0C--></AD_TEXTINTERFACES>
+
 <!--36534EFA1FF843FE8DF205C8EBFC75BC--><AD_TEXTINTERFACES>
 <!--36534EFA1FF843FE8DF205C8EBFC75BC-->  <AD_TEXTINTERFACES_ID><![CDATA[36534EFA1FF843FE8DF205C8EBFC75BC]]></AD_TEXTINTERFACES_ID>
 <!--36534EFA1FF843FE8DF205C8EBFC75BC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Sat Jan 23 12:43:20 2010 +0100
@@ -488,6 +488,7 @@
 
   private static FieldProvider[] formatDeps4Display(ModuleDependency[] deps,
       VariablesSecureApp vars, ConnectionProvider conn) {
+    @SuppressWarnings("unchecked")
     HashMap<String, String>[] res = new HashMap[deps.length];
 
     for (int i = 0; i < deps.length; i++) {
@@ -966,7 +967,10 @@
         }
       }
 
-      if (im.getModulesToInstall().length == 1) {
+      if ((im.getModulesToInstall().length == 1 && im.getModulesToInstall()[0].getModuleID()
+          .equals("0"))
+          || (im.getModulesToUpdate().length == 1 && im.getModulesToUpdate()[0].getModuleID()
+              .equals("0"))) {
         String msgOBPSRequired = Utility.messageBD(this, "OBPS_SUBSCRIPTION_REQUIRED", vars
             .getLanguage());
         msgOBPSRequired = msgOBPSRequired.replace("@MODULE_LIST@", notSubscribed);
--- a/src/org/openbravo/erpCommon/ad_forms/ModuleManagement_ErrorCommercial.html	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/ModuleManagement_ErrorCommercial.html	Sat Jan 23 12:43:20 2010 +0100
@@ -213,29 +213,29 @@
             
             <tr>
               <td class="PlainText_normal" colspan="4" style="padding: 0 0 10 0; text-align: left;">
-                <span id="OBPSInstance-NotActive">
-                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that require acquiring an activation key before installation:&nbsp;<FIELD_TMP id="name"></FIELD_TMP></p>
-                <p><a class="Label_ReadOnly_Text LabelLink_noicon" href="http://www.openbravo.com/product/erp/module/acquire" target="_blank">Learn how</a>&nbsp;to acquire a subscription and activate your instance.</p>
+                <div id="OBPSInstance-NotActive">
+                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that require acquiring an activation key before installation:&nbsp;<FIELD_TMP id="name"></FIELD_TMP><br /></p>
+                <p><a class="Label_ReadOnly_Text LabelLink_noicon" href="http://www.openbravo.com/product/erp/module/acquire" target="_blank">Learn how</a>&nbsp;to acquire modules.</p>
                 <br/>
-                </span>
+                </div>
                 
-                <span id="OBPSInstance-Expired">
-                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that has expired:&nbsp;<FIELD_TMP id="expired"></FIELD_TMP></p>
+                <div id="OBPSInstance-Expired">
+                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that has expired:&nbsp;<FIELD_TMP id="expired"></FIELD_TMP><br /></p>
                 <p><a class="Label_ReadOnly_Text LabelLink_noicon" href="http://www.openbravo.com/product/erp/module/acquire" target="_blank">Learn how</a>&nbsp;to renew licenses for commercial modules.</p>
                 <br/>
-                </span>
+                </div>
                 
-                <span id="OBPSInstance-NoActiveYet">
-                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that is not active yet:&nbsp;<FIELD_TMP id="noActiveYet"></FIELD_TMP></p>
+                <div id="OBPSInstance-NoActiveYet">
+                <p class="Label_ReadOnly_Text">The following module(s) are released under a commercial license that is not active yet:&nbsp;<FIELD_TMP id="noActiveYet"></FIELD_TMP><br /></p>
                 <p><a class="Label_ReadOnly_Text LabelLink_noicon" href="http://www.openbravo.com/product/erp/module/acquire" target="_blank">Learn how</a>&nbsp;to renew licenses for commercial modules.</p>
                 <br/>
-                </span>
+                </div>
                 
-                <span id="CEInstance">
-                <div><FIELD_TMP id="name">xxxModuleDetails</FIELD_TMP></div>
+                <div id="CEInstance">
+                <div><FIELD_TMP id="name">xxxModuleDetails</FIELD_TMP><br /></div>
                 <p><br><a class="Label_ReadOnly_Text LabelLink_noicon" href="http://www.openbravo.com/product/erp/acquire" target="_blank">Learn how</a>&nbsp;to acquire a subscription and activate your instance.</p>
                 <br/>
-                </span>
+                </div>
                </td>
             </tr>
             
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModules.html	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModules.html	Sat Jan 23 12:43:20 2010 +0100
@@ -158,7 +158,7 @@
       var output = minutes_string + ":" + seconds_string;
       document.getElementById(targetvar).innerHTML=output;
 
-      submitXmlHttpRequest(update, frmMain, "UPDATESTATUS", "ApplyModules.html", false, null, null);
+      submitXmlHttpRequest(update, frmMain, "UPDATESTATUS", "ApplyModulesCallServlet.html", false, null, null);
 
       if (lc_isTimerEnabled) {
         setTimeout(function() {LocalTimer(targetvar, referenceDate);},1000);
@@ -372,7 +372,7 @@
             processing = false;
             top.opener.setProcessingMode('window', false);
             var frm = document.frmMain;
-            submitXmlHttpRequest(getError, frm, "GETERR", "ApplyModules.html", false, null, null);
+            submitXmlHttpRequest(getError, frm, "GETERR", "ApplyModulesCallServlet.html", false, null, null);
           }
           start=true;
           var errorStatus=msg.Response.statusofstate;
@@ -382,7 +382,7 @@
             for(i=current_state;i<stateindex;i++){
               //We need to ask for warning/error state for the intermediate status
               document.getElementById("reqStatus").value=possible_states[i];
-              submitXmlHttpRequest(askForErrorStatus, null, "REQUESTERRORSTATE", "ApplyModules.html", false, null, null);
+              submitXmlHttpRequest(askForErrorStatus, null, "REQUESTERRORSTATE", "ApplyModulesCallServlet.html", false, null, null);
             }
           }
  
@@ -408,7 +408,7 @@
     	processing = false;
     	top.opener.setProcessingMode('window', false);
     	var frm = document.frmMain;
-    	return submitXmlHttpRequest(getError, frm, "GETERR", "ApplyModules.html", false, null, null);
+    	return submitXmlHttpRequest(getError, frm, "GETERR", "ApplyModulesCallServlet.html", false, null, null);
       }
     	        
     }
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModules.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModules.java	Sat Jan 23 12:43:20 2010 +0100
@@ -25,7 +25,6 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.Properties;
 import java.util.Vector;
@@ -50,9 +49,6 @@
 import org.openbravo.service.system.RestartTomcat;
 import org.openbravo.xmlEngine.XmlDocument;
 
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
-
 /**
  * Servlet for the Apply Modules method.
  * 
@@ -70,16 +66,10 @@
 
     if (vars.commandIn("DEFAULT")) {
       printPage(request, response, vars);
+    } else if (vars.commandIn("STARTAPPLY")) {
+      startApply(response, vars);
     } else if (vars.commandIn("TOMCAT")) {
       printPageTomcat(request, response, vars);
-    } else if (vars.commandIn("STARTAPPLY")) {
-      startApply(response, vars);
-    } else if (vars.commandIn("UPDATESTATUS")) {
-      update(response, vars);
-    } else if (vars.commandIn("REQUESTERRORSTATE")) {
-      requesterrorstate(response, vars);
-    } else if (vars.commandIn("GETERR")) {
-      getError(response, vars);
     } else if (vars.commandIn("RESTART")) {
       restartApplicationServer(response, vars);
     } else if (vars.commandIn("RELOAD")) {
@@ -90,45 +80,6 @@
   }
 
   /**
-   * Prints the default page for the process, showing the process description and a OK and Cancel
-   * buttons. First it checks whether the server has write permissions to be able to execute the
-   * process.
-   */
-  private void printPage(HttpServletRequest request, HttpServletResponse response,
-      VariablesSecureApp vars) throws IOException, ServletException {
-    // Check for permissions to apply modules from application server.
-    final File f = new File(vars.getSessionValue("#sourcePath"));
-    if (!f.canWrite()) {
-      bdErrorGeneralPopUp(request, response, Utility.messageBD(this, "Error", vars.getLanguage()),
-          Utility.messageBD(this, "NoApplicableModules", vars.getLanguage()));
-      return;
-    }
-
-    String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
-    final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
-        "org/openbravo/erpCommon/ad_process/ApplyModules").createXmlDocument();
-    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
-    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\r\n");
-    xmlDocument.setParameter("theme", vars.getTheme());
-    xmlDocument.setParameter("buttonLog", fileName);
-    xmlDocument.setParameter("logfile", fileName);
-    {
-      final OBError myMessage = vars.getMessage("ApplyModules");
-      vars.removeMessage("ApplyModules");
-      if (myMessage != null) {
-        xmlDocument.setParameter("messageType", myMessage.getType());
-        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
-        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
-      }
-    }
-    response.setContentType("text/html; charset=UTF-8");
-    final PrintWriter out = response.getWriter();
-
-    out.println(xmlDocument.print());
-    out.close();
-  }
-
-  /**
    * Prints a page that only allows the user to restart or reload Tomcat
    */
   private void printPageTomcat(HttpServletRequest request, HttpServletResponse response,
@@ -204,146 +155,42 @@
   }
 
   /**
-   * This method returns an ApplyModulesResponse object, that later is transformed into a JSON
-   * object and resend to the rebuild window.
+   * Prints the default page for the process, showing the process description and a OK and Cancel
+   * buttons. First it checks whether the server has write permissions to be able to execute the
+   * process.
    */
-  private ApplyModulesResponse fillResponse(VariablesSecureApp vars, String state,
-      String defaultState) {
-    String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
-    int lastlinenumber;
-    if (ln == null || ln.equals("")) {
-      lastlinenumber = 0;
-    } else {
-      lastlinenumber = Integer.parseInt(ln);
+  private void printPage(HttpServletRequest request, HttpServletResponse response,
+      VariablesSecureApp vars) throws IOException, ServletException {
+    // Check for permissions to apply modules from application server.
+    final File f = new File(vars.getSessionValue("#sourcePath"));
+    if (!f.canWrite()) {
+      bdErrorGeneralPopUp(request, response, Utility.messageBD(this, "Error", vars.getLanguage()),
+          Utility.messageBD(this, "NoApplicableModules", vars.getLanguage()));
+      return;
     }
-    ApplyModulesResponse resp = new ApplyModulesResponse();
-    resp.setState(Integer.parseInt(state.replace("RB", "")));
-    PreparedStatement ps = null;
-    PreparedStatement ps2 = null;
-    PreparedStatement ps3 = null;
-    boolean warning = false;
-    boolean error = false;
-    int newlinenumber = lastlinenumber;
-    try {
-      ps = getPreparedStatement("SELECT MESSAGE, LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='WARN' AND SYSTEM_STATUS LIKE ?");
-      ps.setString(1, "%" + state);
-      ps.executeQuery();
-      ResultSet rs = ps.getResultSet();
-      ArrayList<String> warnings = new ArrayList<String>();
-      while (rs.next()) {
-        warning = true; // there is at least an warning in this state
-        int linenumber = rs.getInt(2);
-        if (linenumber > newlinenumber) {
-          newlinenumber = linenumber;
-        }
-        if (linenumber > lastlinenumber) {
-          warnings.add(rs.getString(1));
-        }
-      }
-      resp.setWarnings(warnings.toArray(new String[0]));
 
-      ps2 = getPreparedStatement("SELECT MESSAGE, LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' AND SYSTEM_STATUS LIKE ?");
-      ps2.setString(1, "%" + state);
-      ps2.executeQuery();
-      ResultSet rs2 = ps2.getResultSet();
-      ArrayList<String> errors = new ArrayList<String>();
-      while (rs2.next()) {
-        error = true; // there is at least an error in this state
-        int linenumber = rs2.getInt(2);
-        if (linenumber > newlinenumber) {
-          newlinenumber = linenumber;
-        }
-        if (linenumber > lastlinenumber) {
-          errors.add(rs2.getString(1));
-        }
-      }
-      resp.setErrors(errors.toArray(new String[0]));
-
-      ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY CREATED DESC");
-      ps3.executeQuery();
-      ResultSet rs3 = ps3.getResultSet();
-      if (rs3.next()) {
-        resp.setLastmessage(rs3.getString(1));
-      } else {
-        resp.setLastmessage("");
-      }
-
-      vars.setSessionValue("ApplyModules|Last_Line_Number_Log", new Integer(newlinenumber)
-          .toString());
-      if (error)
-        resp.setStatusofstate("Error");
-      else if (warning)
-        resp.setStatusofstate("Warning");
-      else
-        resp.setStatusofstate(defaultState);
-    } catch (Exception e) {
-      log4j.error("Error while building Response object", e);
-    } finally {
-      try {
-        releasePreparedStatement(ps3);
-        releasePreparedStatement(ps2);
-        releasePreparedStatement(ps);
-      } catch (SQLException e2) {
-        log4j.error("Error when closing prepared statements while building response object", e2);
+    String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+    final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
+        "org/openbravo/erpCommon/ad_process/ApplyModules").createXmlDocument();
+    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
+    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\r\n");
+    xmlDocument.setParameter("theme", vars.getTheme());
+    xmlDocument.setParameter("buttonLog", fileName);
+    xmlDocument.setParameter("logfile", fileName);
+    {
+      final OBError myMessage = vars.getMessage("ApplyModules");
+      vars.removeMessage("ApplyModules");
+      if (myMessage != null) {
+        xmlDocument.setParameter("messageType", myMessage.getType());
+        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
+        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
       }
     }
-    return resp;
-  }
+    response.setContentType("text/html; charset=UTF-8");
+    final PrintWriter out = response.getWriter();
 
-  /**
-   * This method is called via AJAX through a timer in the rebuild window. It returns the current
-   * status of the system (and warnings/errors that happened in the current state)
-   */
-  private void update(HttpServletResponse response, VariablesSecureApp vars) {
-    PreparedStatement ps = null;
-    try {
-      ps = getPreparedStatement("SELECT SYSTEM_STATUS FROM AD_SYSTEM_INFO");
-      ps.executeQuery();
-      ResultSet rs = ps.getResultSet();
-      rs.next();
-      String state = rs.getString(1);
-      ApplyModulesResponse resp = fillResponse(vars, state, "Processing");
-      response.setContentType("text/plain; charset=UTF-8");
-      final PrintWriter out = response.getWriter();
-      String strResult;
-      XStream xs = new XStream(new JettisonMappedXmlDriver());
-      xs.alias("Response", ApplyModulesResponse.class);
-      strResult = xs.toXML(resp);
-      out.print(strResult);
-      out.close();
-    } catch (Exception e) {
-      log4j.error("Error while updating the system status in the rebuild window.", e);
-    } finally {
-      if (ps != null)
-        try {
-          releasePreparedStatement(ps);
-        } catch (SQLException e) {
-          log4j.error(
-              "Error while trying to close prepared statement when updating the rebuild window", e);
-        }
-    }
-  }
-
-  /**
-   * This method is called via AJAX, and returns the status and warnings/errors for a particular
-   * state. This method will be called when the Rebuild Window notices that one or more steps were
-   * not updated and the build process already finished them
-   */
-  private void requesterrorstate(HttpServletResponse response, VariablesSecureApp vars) {
-    String state = vars.getStringParameter("reqStatus");
-    ApplyModulesResponse resp = fillResponse(vars, state, "Success");
-    response.setContentType("text/plain; charset=UTF-8");
-    try {
-      final PrintWriter out = response.getWriter();
-      String strResult;
-      XStream xs = new XStream(new JettisonMappedXmlDriver());
-      xs.alias("Response", ApplyModulesResponse.class);
-      strResult = xs.toXML(resp);
-      out.print(strResult);
-      out.close();
-    } catch (IOException e) {
-      log4j.error("Error while updating the system status in the rebuild window.", e);
-    }
+    out.println(xmlDocument.print());
+    out.close();
   }
 
   /**
@@ -435,7 +282,6 @@
       }
       out.close();
     } catch (final Exception e) {
-      log4j.error("Error while updating the system status in the rebuild window.", e);
       // rolback the old transaction and start a new one
       // to store the build log
       OBDal.getInstance().rollbackAndClose();
@@ -453,7 +299,6 @@
         releasePreparedStatement(ps4);
         releasePreparedStatement(updateSession);
       } catch (SQLException e) {
-        log4j.error("Error while updating the system status in the rebuild window.", e);
       }
       OBContext.getOBContext().setInAdministratorMode(admin);
     }
@@ -488,58 +333,6 @@
   }
 
   /**
-   * Method to be called via AJAX. It returns a XML structure with the error messages (if any) or a
-   * Success one
-   */
-  private void getError(HttpServletResponse response, VariablesSecureApp vars) throws IOException,
-      ServletException {
-    OBError error = new OBError();
-    PreparedStatement ps;
-    PreparedStatement ps2;
-    try {
-      ps = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR'");
-      ps.executeQuery();
-      ResultSet rs = ps.getResultSet();
-      if (rs.next()) {
-        error.setType("Error");
-        error.setTitle(Utility.messageBD(myPool, "Error", vars.getLanguage()));
-        error.setMessage(Utility.messageBD(myPool, "BuildError", vars.getLanguage())
-            + "<a href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\" target=\"_blank\">"
-            + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) + "</a>.");
-
-      } else {
-        ps2 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE ERROR_LEVEL='WARN'");
-        ps2.executeQuery();
-        ResultSet rs2 = ps2.getResultSet();
-        if (rs2.next()) {
-          error.setType("Warning");
-          error.setTitle(Utility.messageBD(myPool, "Warning", vars.getLanguage()));
-          error
-              .setMessage(Utility.messageBD(myPool, "BuildWarning", vars.getLanguage())
-                  + "<a href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\" target=\"_blank\">"
-                  + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) + "</a>."
-                  + Utility.messageBD(myPool, "BuildWarning2", vars.getLanguage()));
-
-        } else {
-          error.setType("Success");
-          error.setTitle(Utility.messageBD(myPool, "Success", vars.getLanguage()));
-          error.setMessage(Utility.messageBD(myPool, "BuildSuccessful", vars.getLanguage()));
-        }
-      }
-    } catch (Exception e) {
-      log4j.error("Error while returning the error to the rebuild window", e);
-    }
-
-    XStream xs = new XStream(new JettisonMappedXmlDriver());
-    xs.alias("OBError", OBError.class);
-    String strResult = xs.toXML(error);
-    response.setContentType("text/html; charset=UTF-8");
-    final PrintWriter out = response.getWriter();
-    out.print(strResult);
-    out.close();
-  }
-
-  /**
    * Returns a String of comma separated values for all the modules that are installed but not
    * applied
    * 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java	Sat Jan 23 12:43:20 2010 +0100
@@ -0,0 +1,262 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2010 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.ad_process;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openbravo.base.HttpBaseServlet;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.Utility;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
+
+public class ApplyModulesCallServlet extends HttpBaseServlet {
+  private static final long serialVersionUID = 1L;
+
+  /**
+     * 
+     */
+  @Override
+  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
+      ServletException {
+    final VariablesSecureApp vars = new VariablesSecureApp(request);
+
+    if (vars.commandIn("UPDATESTATUS")) {
+      update(response, vars);
+    } else if (vars.commandIn("REQUESTERRORSTATE")) {
+      requesterrorstate(response, vars);
+    } else if (vars.commandIn("GETERR")) {
+      getError(response, vars);
+    }
+  }
+
+  /**
+   * This method returns an ApplyModulesResponse object, that later is transformed into a JSON
+   * object and resend to the rebuild window.
+   */
+  private ApplyModulesResponse fillResponse(VariablesSecureApp vars, String state,
+      String defaultState) {
+    String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
+    if (ln == null || ln.equals("")) {
+      return null;
+    }
+    int lastlinenumber;
+    if (ln == null || ln.equals("")) {
+      lastlinenumber = 0;
+    } else {
+      lastlinenumber = Integer.parseInt(ln);
+    }
+    ApplyModulesResponse resp = new ApplyModulesResponse();
+    resp.setState(Integer.parseInt(state.replace("RB", "")));
+    PreparedStatement ps = null;
+    PreparedStatement ps2 = null;
+    PreparedStatement ps3 = null;
+    boolean warning = false;
+    boolean error = false;
+    int newlinenumber = lastlinenumber;
+    try {
+      ps = getPreparedStatement("SELECT MESSAGE, LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='WARN' AND SYSTEM_STATUS LIKE ?");
+      ps.setString(1, "%" + state);
+      ps.executeQuery();
+      ResultSet rs = ps.getResultSet();
+      ArrayList<String> warnings = new ArrayList<String>();
+      while (rs.next()) {
+        warning = true; // there is at least an warning in this state
+        int linenumber = rs.getInt(2);
+        if (linenumber > newlinenumber) {
+          newlinenumber = linenumber;
+        }
+        if (linenumber > lastlinenumber) {
+          warnings.add(rs.getString(1));
+        }
+      }
+      resp.setWarnings(warnings.toArray(new String[0]));
+
+      ps2 = getPreparedStatement("SELECT MESSAGE, LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' AND SYSTEM_STATUS LIKE ?");
+      ps2.setString(1, "%" + state);
+      ps2.executeQuery();
+      ResultSet rs2 = ps2.getResultSet();
+      ArrayList<String> errors = new ArrayList<String>();
+      while (rs2.next()) {
+        error = true; // there is at least an error in this state
+        int linenumber = rs2.getInt(2);
+        if (linenumber > newlinenumber) {
+          newlinenumber = linenumber;
+        }
+        if (linenumber > lastlinenumber) {
+          errors.add(rs2.getString(1));
+        }
+      }
+      resp.setErrors(errors.toArray(new String[0]));
+
+      ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY CREATED DESC");
+      ps3.executeQuery();
+      ResultSet rs3 = ps3.getResultSet();
+      if (rs3.next()) {
+        resp.setLastmessage(rs3.getString(1));
+      } else {
+        resp.setLastmessage("");
+      }
+
+      vars.setSessionValue("ApplyModules|Last_Line_Number_Log", new Integer(newlinenumber)
+          .toString());
+      if (error)
+        resp.setStatusofstate("Error");
+      else if (warning)
+        resp.setStatusofstate("Warning");
+      else
+        resp.setStatusofstate(defaultState);
+    } catch (Exception e) {
+    } finally {
+      try {
+        releasePreparedStatement(ps3);
+        releasePreparedStatement(ps2);
+        releasePreparedStatement(ps);
+      } catch (SQLException e2) {
+      }
+    }
+    return resp;
+  }
+
+  /**
+   * This method is called via AJAX through a timer in the rebuild window. It returns the current
+   * status of the system (and warnings/errors that happened in the current state)
+   */
+  private void update(HttpServletResponse response, VariablesSecureApp vars) {
+    String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
+    if (ln == null || ln.equals("")) {
+      return;
+    }
+    PreparedStatement ps = null;
+    try {
+      ps = getPreparedStatement("SELECT SYSTEM_STATUS FROM AD_SYSTEM_INFO");
+      ps.executeQuery();
+      ResultSet rs = ps.getResultSet();
+      rs.next();
+      String state = rs.getString(1);
+      ApplyModulesResponse resp = fillResponse(vars, state, "Processing");
+      response.setContentType("text/plain; charset=UTF-8");
+      final PrintWriter out = response.getWriter();
+      String strResult;
+      XStream xs = new XStream(new JettisonMappedXmlDriver());
+      xs.alias("Response", ApplyModulesResponse.class);
+      strResult = xs.toXML(resp);
+      out.print(strResult);
+      out.close();
+    } catch (Exception e) {
+    } finally {
+      if (ps != null)
+        try {
+          releasePreparedStatement(ps);
+        } catch (SQLException e) {
+        }
+    }
+  }
+
+  /**
+   * This method is called via AJAX, and returns the status and warnings/errors for a particular
+   * state. This method will be called when the Rebuild Window notices that one or more steps were
+   * not updated and the build process already finished them
+   */
+  private void requesterrorstate(HttpServletResponse response, VariablesSecureApp vars) {
+    String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
+    if (ln == null || ln.equals("")) {
+      return;
+    }
+    String state = vars.getStringParameter("reqStatus");
+    ApplyModulesResponse resp = fillResponse(vars, state, "Success");
+    response.setContentType("text/plain; charset=UTF-8");
+    try {
+      final PrintWriter out = response.getWriter();
+      String strResult;
+      XStream xs = new XStream(new JettisonMappedXmlDriver());
+      xs.alias("Response", ApplyModulesResponse.class);
+      strResult = xs.toXML(resp);
+      out.print(strResult);
+      out.close();
+    } catch (IOException e) {
+    }
+  }
+
+  /**
+   * Method to be called via AJAX. It returns a XML structure with the error messages (if any) or a
+   * Success one
+   */
+  private void getError(HttpServletResponse response, VariablesSecureApp vars) throws IOException,
+      ServletException {
+    String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
+    if (ln == null || ln.equals("")) {
+      return;
+    }
+    OBError error = new OBError();
+    PreparedStatement ps;
+    PreparedStatement ps2;
+    try {
+      ps = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR'");
+      ps.executeQuery();
+      ResultSet rs = ps.getResultSet();
+      if (rs.next()) {
+        error.setType("Error");
+        error.setTitle(Utility.messageBD(myPool, "Error", vars.getLanguage()));
+        error.setMessage(Utility.messageBD(myPool, "BuildError", vars.getLanguage())
+            + "<a href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\" target=\"_blank\">"
+            + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) + "</a>.");
+
+      } else {
+        ps2 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE ERROR_LEVEL='WARN'");
+        ps2.executeQuery();
+        ResultSet rs2 = ps2.getResultSet();
+        if (rs2.next()) {
+          error.setType("Warning");
+          error.setTitle(Utility.messageBD(myPool, "Warning", vars.getLanguage()));
+          error
+              .setMessage(Utility.messageBD(myPool, "BuildWarning", vars.getLanguage())
+                  + "<a href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\" target=\"_blank\">"
+                  + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) + "</a>."
+                  + Utility.messageBD(myPool, "BuildWarning2", vars.getLanguage()));
+
+        } else {
+          error.setType("Success");
+          error.setTitle(Utility.messageBD(myPool, "Success", vars.getLanguage()));
+          error.setMessage(Utility.messageBD(myPool, "BuildSuccessful", vars.getLanguage()));
+        }
+      }
+    } catch (Exception e) {
+    }
+
+    XStream xs = new XStream(new JettisonMappedXmlDriver());
+    xs.alias("OBError", OBError.class);
+    String strResult = xs.toXML(error);
+    response.setContentType("text/html; charset=UTF-8");
+    final PrintWriter out = response.getWriter();
+    out.print(strResult);
+    out.close();
+  }
+}
--- a/src/org/openbravo/erpCommon/ad_reports/AccountNumberCombo_data.xsql	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/AccountNumberCombo_data.xsql	Sat Jan 23 12:43:20 2010 +0100
@@ -28,12 +28,13 @@
     <SqlMethodComment></SqlMethodComment>
     <Sql>
     <![CDATA[
-      SELECT C_BANKACCOUNT_ID AS ID, (C_BANK.NAME || '-' || COALESCE(TO_CHAR(C_BANK.CODEBANK),'') || '/' || COALESCE(TO_CHAR(C_BANK.CODEBRANCH),'') || COALESCE(TO_CHAR(C_BANK.DIGITCONTROL),'') || COALESCE(TO_CHAR(C_BANKACCOUNT.DIGITCONTROL),'') || COALESCE(TO_CHAR(C_BANKACCOUNT.CODEACCOUNT),'')) AS name
+      SELECT AD_COLUMN_IDENTIFIER(TO_CHAR('C_BankAccount'), TO_CHAR(C_BANKACCOUNT.C_BANKACCOUNT_ID), TO_CHAR(?)) AS name
       FROM C_BANK, C_BANKACCOUNT
       WHERE C_BANK.C_BANK_ID = C_BANKACCOUNT.C_BANK_ID 
       AND C_BANK.AD_CLIENT_ID IN ('1')
       AND C_BANK.AD_ORG_ID IN ('1')
      ]]></Sql>
+    <Parameter name="language"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="AND C_BANK.AD_CLIENT_ID IN (" text="'1'"/>
     <Parameter name="adUserOrg" type="replace" optional="true" after="AND C_BANK.AD_ORG_ID IN (" text="'1'"/>
   </SqlMethod>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportBank.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportBank.java	Sat Jan 23 12:43:20 2010 +0100
@@ -115,8 +115,8 @@
     xmlDocument.setParameter("paramMessage", (strMessage.equals("") ? "" : "alert('" + strMessage
         + "');"));
     xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-        this, Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(
-            this, vars, "#AccessibleOrgTree", "ReportBank")));
+        this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportBank"),
+        Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportBank")));
 
     out.println(xmlDocument.print());
     out.close();
@@ -156,8 +156,8 @@
       xmlDocument.setParameter("paramMessage", (strMessage.equals("") ? "" : "alert('" + strMessage
           + "');"));
       xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-          this, Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(
-              this, vars, "#AccessibleOrgTree", "ReportBank")));
+          this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportBank"),
+          Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportBank")));
     } else {
       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportBankEdit")
           .createXmlDocument();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportBankJR.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportBankJR.java	Sat Jan 23 12:43:20 2010 +0100
@@ -123,8 +123,8 @@
     xmlDocument.setParameter("paramMessage", (strMessage.equals("") ? "" : "alert('" + strMessage
         + "');"));
     xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-        this, Utility.getContext(this, vars, "#User_Client", "ReportBankJR"), Utility.getContext(
-            this, vars, "#AccessibleOrgTree", "ReportBankJR")));
+        this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportBankJR"),
+        Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportBankJR")));
 
     out.println(xmlDocument.print());
     out.close();
@@ -163,8 +163,8 @@
       xmlDocument.setParameter("paramMessage", (strMessage.equals("") ? "" : "alert('" + strMessage
           + "');"));
       xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-          this, Utility.getContext(this, vars, "#User_Client", "ReportBankJR"), Utility.getContext(
-              this, vars, "#AccessibleOrgTree", "ReportBankJR")));
+          this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportBankJR"),
+          Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportBankJR")));
     } else {
       // initialBalance = new BigDecimal(
       // ReportBankJRData.BeginningBalance(this, Utility.getContext(this,
--- a/src/org/openbravo/erpCommon/ad_reports/ReportCashflowForecast.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportCashflowForecast.java	Sat Jan 23 12:43:20 2010 +0100
@@ -92,9 +92,10 @@
     // ReportCashflowForecastData[] dataSummary =
     // ReportCashflowForecastData.select(this,Utility.getContext(this, vars, "#User_Client",
     // "ReportBank"), Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportBank"));
-    ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this, strDateMax,
-        "", Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this,
-            vars, "#AccessibleOrgTree", "ReportBank"));
+    ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this, vars
+        .getLanguage(), strDateMax, "", Utility
+        .getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars,
+        "#AccessibleOrgTree", "ReportBank"));
 
     if (!showDefault) {
       ReportCashflowForecastData[] dataDetail = null;
@@ -167,9 +168,10 @@
     // ReportCashflowForecastData.select(this,Utility.getContext(this, vars,
     // "#User_Client", "ReportBank"), Utility.getContext(this, vars,
     // "#AccessibleOrgTree", "ReportBank"));
-    ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this, strDateMax,
-        "", Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this,
-            vars, "#AccessibleOrgTree", "ReportBank"));
+    ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this, vars
+        .getLanguage(), strDateMax, "", Utility
+        .getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars,
+        "#AccessibleOrgTree", "ReportBank"));
 
     if (!showDefault) {
       ReportCashflowForecastData[][] data = null;
@@ -178,9 +180,9 @@
 
       // dataAcct = ReportCashflowForecastData.select(this, strDateMax,
       // strBankAccount);
-      dataAcct = ReportCashflowForecastData.select(this, strDateMax, strBankAccount, Utility
-          .getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars,
-          "#AccessibleOrgTree", "ReportBank"));
+      dataAcct = ReportCashflowForecastData.select(this, vars.getLanguage(), strDateMax,
+          strBankAccount, Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility
+              .getContext(this, vars, "#AccessibleOrgTree", "ReportBank"));
       data = new ReportCashflowForecastData[dataAcct.length][];
 
       if (log4j.isDebugEnabled())
@@ -221,8 +223,9 @@
     toolbar.prepareSimpleToolBarTemplate();
     xmlDocument.setParameter("toolbar", toolbar.toString());
     xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-        this, Utility.getContext(this, vars, "#User_Client", "ReportCashflowForecast"), Utility
-            .getContext(this, vars, "#AccessibleOrgTree", "ReportCashflowForecast")));
+        this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client",
+            "ReportCashflowForecast"), Utility.getContext(this, vars, "#AccessibleOrgTree",
+            "ReportCashflowForecast")));
     xmlDocument.setParameter("cBankAccount", strBankAccount);
     xmlDocument.setParameter("dateFrom", strDateMax);
     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
--- a/src/org/openbravo/erpCommon/ad_reports/ReportCashflowForecast_data.xsql	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportCashflowForecast_data.xsql	Sat Jan 23 12:43:20 2010 +0100
@@ -27,7 +27,7 @@
   <SqlMethod name="select" type="preparedStatement" return="multiple">
     <Sql>
     <![CDATA[
-      SELECT BANKACCOUNT, 
+      SELECT AD_COLUMN_IDENTIFIER(TO_CHAR('C_BankAccount'), TO_CHAR(BANKACCOUNTID), TO_CHAR(?)) as BANKACCOUNT, 
              INITIALBALANCE,
              TRUNC(NOW()) AS CURRENTDATE, 
              INCOME, 
@@ -45,7 +45,7 @@
              '' AS ISRECEIPT,
              '' AS URL,
              '' AS ISRECEIPTMESSAGE FROM (     
-            SELECT (B.CODEBANK || '/' || B.CODEBRANCH || B.DIGITCONTROL || BA.CODEACCOUNT || '.' || BA.DIGITCONTROL) AS BANKACCOUNT,
+            SELECT BA.C_BANKACCOUNT_ID AS BANKACCOUNTID,
              SUM(c_currency_convert(STMTAMT, BL.C_CURRENCY_ID, BA.C_CURRENCY_ID, BL.VALUTADATE, NULL, ba.ad_client_id, ba.ad_org_id)) AS INITIALBALANCE,
              COALESCE((SELECT SUM(c_currency_convert(DP.AMOUNT, dp.C_CURRENCY_ID, ba.c_Currency_ID, dp.dateplanned,null, ba.ad_client_id, ba.ad_org_id))
                 FROM C_DEBT_PAYMENT_V DP
@@ -98,26 +98,25 @@
              BA.C_BANKACCOUNT_ID
       FROM C_BANKSTATEMENTLINE BL,
            C_BANKSTATEMENT     BS,
-           C_BANK              B,
            C_BANKACCOUNT       BA
       WHERE BS.C_BANKSTATEMENT_ID = BL.C_BANKSTATEMENT_ID
         AND BA.C_BANKACCOUNT_ID = BS.C_BANKACCOUNT_ID
-        AND BA.C_BANK_ID = B.C_BANK_ID 
         AND BS.PROCESSED='Y'  
         AND BS.STATEMENTDATE <= NOW()
         AND 3=3
-        AND B.AD_CLIENT_ID IN ('1')
-        AND B.AD_ORG_ID IN ('1') 
-       GROUP BY (B.CODEBANK || '/' || B.CODEBRANCH || B.DIGITCONTROL || BA.CODEACCOUNT || '.' || BA.DIGITCONTROL), BA.C_BANKACCOUNT_ID, ba.c_Currency_ID, ba.ad_client_id, ba.ad_org_id 
+        AND BA.AD_CLIENT_ID IN ('1')
+        AND BA.AD_ORG_ID IN ('1') 
+       GROUP BY BA.C_BANKACCOUNT_ID, ba.c_Currency_ID, ba.ad_client_id, ba.ad_org_id 
        ) AAA  
        ORDER BY 1
      ]]></Sql>
     <Field name="rownum" value="count"/>
+    <Parameter name="language"/>
     <Parameter name="dateMax" optional="true" after="AND 1=1"><![CDATA[ AND DP.DATEPLANNED <= TO_DATE(?) ]]></Parameter>
     <Parameter name="dateMax" optional="true" after="AND 2=2"><![CDATA[ AND DP.DATEPLANNED <= TO_DATE(?) ]]></Parameter>
     <Parameter name="bankaccount" optional="true" after="AND 3=3"><![CDATA[ AND BA.C_BANKACCOUNT_ID = ? ]]></Parameter>
-    <Parameter name="adUserClient" type="replace" optional="true" after="AND B.AD_CLIENT_ID IN (" text="'1'"/>
-    <Parameter name="adUserOrg" type="replace" optional="true" after="AND B.AD_ORG_ID IN (" text="'1'"/> 
+    <Parameter name="adUserClient" type="replace" optional="true" after="AND BA.AD_CLIENT_ID IN (" text="'1'"/>
+    <Parameter name="adUserOrg" type="replace" optional="true" after="AND BA.AD_ORG_ID IN (" text="'1'"/> 
   </SqlMethod>
 
  <SqlMethod name="selectLines" type="preparedStatement" return="multiple">
--- a/src/org/openbravo/erpCommon/ad_reports/ReportDebtPayment.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportDebtPayment.java	Sat Jan 23 12:43:20 2010 +0100
@@ -373,8 +373,9 @@
     xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";");
     xmlDocument.setParameter("cBankAccount", strcbankaccount);
     xmlDocument.setData("reportC_ACCOUNTNUMBER", "liststructure", AccountNumberComboData.select(
-        this, Utility.getContext(this, vars, "#User_Client", "ReportDebtPayment"), Utility
-            .getContext(this, vars, "#AccessibleOrgTree", "ReportDebtPayment")));
+        this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client",
+            "ReportDebtPayment"), Utility.getContext(this, vars, "#AccessibleOrgTree",
+            "ReportDebtPayment")));
     xmlDocument.setData("reportCBPartnerId_IN", "liststructure", SelectorUtilityData
         .selectBpartner(this, Utility.getContext(this, vars, "#AccessibleOrgTree", ""), Utility
             .getContext(this, vars, "#User_Client", ""), strC_BPartner_ID));
--- a/src/org/openbravo/erpCommon/security/Login_F1.html	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html	Sat Jan 23 12:43:20 2010 +0100
@@ -78,7 +78,7 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if ((!revisionControl('5956')) || (isOpsInstance() != isOpsInstanceCached())) {
+    if ((!revisionControl('5959')) || (isOpsInstance() != isOpsInstanceCached())) {
       alert("Your browser's cache has outdated files. Please clean it and reload the page.");
     }
   }
--- a/src/org/openbravo/erpCommon/utility/UsedByLink.java	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/UsedByLink.java	Sat Jan 23 12:43:20 2010 +0100
@@ -181,12 +181,20 @@
     xmlDocument.setParameter("tabID", TabId);
     xmlDocument.setParameter("windowID", strWindow);
     xmlDocument.setParameter("keyColumn", keyColumn);
-    xmlDocument.setParameter("keyName", "inp" + Sqlc.TransformaNombreColumna(keyColumn));
-    xmlDocument.setParameter("keyId", keyId);
     xmlDocument.setParameter("adTabId", strAD_TAB_ID);
     xmlDocument.setParameter("tableName", strTABLENAME);
-    xmlDocument.setParameter("columnName", strCOLUMNNAME);
     xmlDocument.setParameter("tableId", adTableId);
+    // We have to check whether we have self reference or not
+    String selfReferenceCount = UsedByLinkData.getCountOfSelfReference(this, adTableId,
+        strTABLENAME);
+    if (selfReferenceCount.equals("0")) {
+      xmlDocument.setParameter("keyName", "inp" + Sqlc.TransformaNombreColumna(keyColumn));
+      xmlDocument.setParameter("keyId", keyId);
+      xmlDocument.setParameter("columnName", strCOLUMNNAME);
+    } else {
+      xmlDocument.setParameter("columnName", keyColumn);
+    }
+
     xmlDocument.setParameter("recordIdentifier", UsedByLinkData.selectIdentifier(this, keyId, vars
         .getLanguage(), adTableId));
     if (vars.getLanguage().equals("en_US")) {
--- a/src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql	Fri Jan 22 17:02:32 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/UsedByLink_data.xsql	Sat Jan 23 12:43:20 2010 +0100
@@ -334,4 +334,17 @@
     <Parameter name="language"/>
     <Parameter name="adTableId"/>
   </SqlMethod>
+  <SqlMethod name="getCountOfSelfReference" type="preparedStatement" return="String" default="0">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT count(*) as ID 
+        FROM AD_TABLE 
+        WHERE AD_TABLE_ID = ? 
+        AND TABLENAME = ?
+      ]]>
+    </Sql>
+    <Parameter name="adTableId"/>
+    <Parameter name="tableName"/>
+  </SqlMethod>
 </SqlClass>
--- a/web/js/utils.js	Fri Jan 22 17:02:32 2010 +0100
+++ b/web/js/utils.js	Sat Jan 23 12:43:20 2010 +0100
@@ -70,7 +70,7 @@
 * Return a number that would be checked at the Login screen to know if the file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '5956';
+  var number = '5959';
   return number;
 }
 
@@ -841,7 +841,11 @@
   } else {
     var winPopUp = window.open((doSubmit?"":url), _name, adds);
   }
-  winPopUp.onunload = function(){putFocusOnMenu();}
+  winPopUp.onunload = function() {
+    if (winPopUp.location.href != "about:blank" && winPopUp.location.href.indexOf("utility/PopupLoading.html") == -1) {
+      putFocusOnMenu();
+    }
+  }
   if (closeControl) window.onunload = function(){winPopUp.close();}
   if (doSubmit) {
     if (isPopup==true && hasLoading == true) synchronizedSubmitCommandForm(getArrayValue(parameters, "Command", "DEFAULT"), (getArrayValue(parameters, "debug", false)==true), null, url, _name, target, checkChanges);