[mod-check] merge with pi
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 26 Nov 2009 16:35:30 +0100
changeset 5550 055ee9baf5df
parent 5549 08b700142435 (current diff)
parent 5497 0e8f7295dc15 (diff)
child 5551 7a30caea85b5
[mod-check] merge with pi
build.xml
src-db/database/lib/dbsourcemanager.jar
src-wad/src/org/openbravo/wad/Imports_data.xsql
src/org/openbravo/erpCommon/ad_process/AssetDelivery_data.xsql
--- a/build.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/build.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -536,10 +536,6 @@
     <ant dir="${base.db}" target="update.database.mod" inheritAll="true" inheritRefs="true" />
   </target>
 
-  <target name="update.customized.database" depends="init, core.lib, database.lib">
-    <ant dir="${base.db}" target="update.customized.database" inheritAll="true" inheritRefs="true" />
-  </target>
-
   <target name="create.database.script" depends="init, core.lib">
     <ant dir="${base.db}" target="create.database.script" inheritAll="true" inheritRefs="true" />
   </target>
--- a/config/Openbravo.properties.template	Thu Nov 26 16:11:17 2009 +0100
+++ b/config/Openbravo.properties.template	Thu Nov 26 16:35:30 2009 +0100
@@ -14,7 +14,7 @@
 # * All Rights Reserved. 
 # * Contributor(s):  ______________________________________.
 # ************************************************************************
-
+#
 # Documentation at http://wiki.openbravo.com/wiki/Openbravo.properties
 
 ####################
--- a/src-db/database/build-create.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/build-create.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -249,7 +249,6 @@
           DELETE FROM AD_REGISTRATION_INFO;
           INSERT INTO AD_REGISTRATION_INFO(AD_REGISTRATION_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
           VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0');
-          CALL AD_UPDATE_SEQUENCE();
           CALL AD_UPDATE_ACCESS();
           SELECT AD_DB_MODIFIED('Y') FROM DUAL;
           UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
@@ -289,7 +288,6 @@
           DELETE FROM AD_REGISTRATION_INFO;
           INSERT INTO AD_REGISTRATION_INFO(AD_REGISTRATION_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
           VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0');
-          SELECT AD_UPDATE_SEQUENCE();
           SELECT AD_UPDATE_ACCESS();
           SELECT AD_DB_MODIFIED('Y');
           UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
--- a/src-db/database/build.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/build.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -128,7 +128,6 @@
       </classpath>
       <transaction>
           UPDATE AD_SYSTEM_INFO SET CODE_REVISION=SUBSTR('${code.revision}',1,60);
-          CALL AD_UPDATE_SEQUENCE();
           CALL AD_UPDATE_ACCESS();
           UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
           CALL AD_LANGUAGE_CREATE(NULL);
@@ -146,7 +145,6 @@
       </classpath>
       <transaction>
           UPDATE AD_SYSTEM_INFO SET CODE_REVISION=SUBSTR('${code.revision}',1,60);
-          SELECT AD_UPDATE_SEQUENCE();
           SELECT AD_UPDATE_ACCESS();
           UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
           SELECT AD_LANGUAGE_CREATE(NULL);
Binary file src-db/database/lib/dbsourcemanager.jar has changed
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -1423,7 +1423,8 @@
             CurLines RECORD;
             p_DateInvoiced DATE;
             v_totalQtyInvoiced NUMBER;
-            v_NewPendingToInvoice NUMBER;
+            v_ODocumentNo C_ORDER.DocumentNo%TYPE;
+            v_NewPendingToInvoice NUMBER;            
             v_deliveredQty NUMBER;
             v_inOutStatus varchar2(60) ;
           BEGIN
@@ -1436,14 +1437,16 @@
             LOOP
               IF(CurLines.C_OrderLine_ID IS NOT NULL) THEN
                 --Check that qty pending to invoice is higher or equal to the qty being invoiced
-                SELECT qtyordered - qtyinvoiced - CurLines.QtyInvoiced
-                  INTO v_NewPendingToInvoice
-                FROM c_orderline
-                WHERE c_orderline.c_orderline_id = CurLines.c_orderline_id;
+                SELECT o.documentno, ABS(ol.qtyordered) - ABS(ol.qtyinvoiced + CurLines.QtyInvoiced)
+                  INTO v_ODocumentNo, v_NewPendingToInvoice
+                FROM c_order o, c_orderline ol
+                WHERE o.c_order_id = ol.c_order_id
+                AND ol.c_orderline_id = CurLines.c_orderline_id;
                 IF (v_NewPendingToInvoice <0 ) THEN
                   v_Message := '@NotPossibleCompleteInvoice@' || ' ' || v_DocumentNo;
-                  v_Message := v_Message || ' ' || '@line@' || CurLines.line || '. ';
-                  v_Message := v_Message || '@QtyInvoicedHigherOrdered@';
+                  v_Message := v_Message || ' ' || '@line@' || ' ' || CurLines.line || '. ';
+                  v_Message := v_Message || '@OrderDocumentno@' || ' ' || v_ODocumentNo;
+                  v_Message := v_Message || ': ' || '@QtyInvoicedHigherOrdered@' || '.';                  
                   RAISE_APPLICATION_ERROR(-20000, v_Message);
                 END IF;
                 UPDATE C_ORDERLINE
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -505,7 +505,7 @@
             and c_order.invoicerule in ('D', 'O', 'S')
             and c_invoice.processed='Y'
           group by m_inoutline.m_inoutline_id, m_inoutline.line
-          having sum(c_invoiceline.qtyinvoiced) > 0
+          having sum(c_invoiceline.qtyinvoiced) <> 0
           ) a;
           IF (v_count > 0 ) THEN
             v_Message := '@InoutDocumentno@' || ': ' || Cur_InOut.DocumentNo || ' ' || '@line@' || ': ' || v_line || '. ';
--- a/src-db/database/model/tables/MA_PROCESSPLAN.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/tables/MA_PROCESSPLAN.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -68,7 +68,7 @@
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
       <unique name="MA_PROCESSPLAN_VALUE">
-        <unique-column name="AD_CLIENT_ID"/>
+        <unique-column name="AD_ORG_ID"/>
         <unique-column name="VALUE"/>
       </unique>
       <check name="MA_PROCESSPLAN_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
--- a/src-db/database/model/triggers/AD_TABLE_TRG.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/triggers/AD_TABLE_TRG.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -65,16 +65,17 @@
      IF v_Aux = 0 THEN
        RAISE_APPLICATION_ERROR(-20536, 'Names must start with its module''s DB prefix ') ;
      END IF;
+
+     --Check Name for illegal characters
+     FOR I IN 1..LENGTH(trim(:NEW.name)) LOOP
+        v_char := substr(trim(:NEW.name),i,1);
+        IF v_char = ' ' or v_char = '.' or v_char = ',' or v_char='/' THEN
+           RAISE_APPLICATION_ERROR(-20635, '@NameWithInvalidCharacters@') ;
+        END IF;
+     END LOOP;
+
   END IF;
 
-  --Check Name for illegal characters
-  FOR I IN 1..LENGTH(trim(:NEW.name)) LOOP
-     v_char := substr(trim(:NEW.name),i,1);
-     IF v_char = ' ' or v_char = '.' or v_char='/' THEN
-         RAISE_APPLICATION_ERROR(-20635, '@NameWithInvalidCharacters@') ;
-     END IF;
-  END LOOP;
-
 END AD_TABLE_TRG
 ]]></body>
     </trigger>
--- a/src-db/database/model/triggers/AD_WINDOW_TRG.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/triggers/AD_WINDOW_TRG.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -105,8 +105,8 @@
                        where m.ad_module_id = ad_menu.ad_module_id
                        and m1.ad_module_id = :new.ad_module_id
                        and ad_menu.AD_WINDOW_ID = :new.AD_Window_ID
-                       and m1.ad_language = m.ad_language
-                       and AD_Menu_Trl.ad_language = m1.ad_language);
+                       and AD_Menu_Trl.ad_language = m1.ad_language
+                       and AD_Menu_Trl.ad_menu_id = ad_menu.ad_menu_id);
         
     IF (COALESCE(:old.IsActive, '.') <> COALESCE(:NEW.IsActive, '.')) THEN
         -- Update Menu
--- a/src-db/database/model/triggers/C_ORDLINE_CHK_RESTRICTIONS_TRG.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/model/triggers/C_ORDLINE_CHK_RESTRICTIONS_TRG.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -70,7 +70,7 @@
         ELSIF (v_IsSOTrx ='Y' AND v_DocStatus = 'DR' AND (:OLD.QTYDELIVERED <> 0 OR :OLD.QTYINVOICED <> 0)) THEN
           RAISE_APPLICATION_ERROR(-20000, '@DeliveredInvoicedOrderline@');
         END IF;
-      ELSIF (v_IsSOTrx = 'Y' AND :new.QtyInvoiced > :new.QtyOrdered) THEN
+      ELSIF (v_IsSOTrx = 'Y' AND ABS(:new.QtyInvoiced) > ABS(:new.QtyOrdered)) THEN
         v_Message := '@OrderDocumentno@' || ' ' || v_DocumentNo || ' ' || '@line@' || :old.line || '. ';
         v_Message := v_Message || '@QtyInvoicedHigherOrdered@';
         RAISE_APPLICATION_ERROR(-20000, v_Message);
--- a/src-db/database/sourcedata/AD_VAL_RULE.xml	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-db/database/sourcedata/AD_VAL_RULE.xml	Thu Nov 26 16:35:30 2009 +0100
@@ -1259,7 +1259,7 @@
 <!--299FA667CF374AC5ACC74739C3251134-->  <NAME><![CDATA[C_Tax IsSOTrx]]></NAME>
 <!--299FA667CF374AC5ACC74739C3251134-->  <DESCRIPTION><![CDATA[Validate tax depending on is Sales or Purchase transaction]]></DESCRIPTION>
 <!--299FA667CF374AC5ACC74739C3251134-->  <TYPE><![CDATA[S]]></TYPE>
-<!--299FA667CF374AC5ACC74739C3251134-->  <CODE><![CDATA[C_TAX.SOPOTYPE =(CASE WHEN @IsSOTrx@ = 'Y' THEN 'S' ELSE 'P' END) OR C_TAX.SOPOTYPE = 'B']]></CODE>
+<!--299FA667CF374AC5ACC74739C3251134-->  <CODE><![CDATA[(C_TAX.SOPOTYPE =(CASE WHEN @IsSOTrx@ = 'Y' THEN 'S' ELSE 'P' END) OR C_TAX.SOPOTYPE = 'B') AND C_TAX.AD_CLIENT_ID=@AD_CLIENT_ID@]]></CODE>
 <!--299FA667CF374AC5ACC74739C3251134-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--299FA667CF374AC5ACC74739C3251134--></AD_VAL_RULE>
 
--- a/src-test/org/openbravo/test/AllAntTaskTests.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-test/org/openbravo/test/AllAntTaskTests.java	Thu Nov 26 16:35:30 2009 +0100
@@ -25,7 +25,6 @@
 import org.openbravo.test.dal.DalComplexQueryRequisitionTest;
 import org.openbravo.test.dal.DalComplexQueryTestOrderLine;
 import org.openbravo.test.dal.DalConnectionProviderTest;
-import org.openbravo.test.dal.DalCopyTest;
 import org.openbravo.test.dal.DalPerformanceInventoryLineTest;
 import org.openbravo.test.dal.DalPerformanceProductTest;
 import org.openbravo.test.dal.DalQueryTest;
@@ -33,6 +32,7 @@
 import org.openbravo.test.dal.DalTest;
 import org.openbravo.test.dal.DynamicEntityTest;
 import org.openbravo.test.dal.HiddenUpdateTest;
+import org.openbravo.test.dal.IssuesTest;
 import org.openbravo.test.dal.MappingGenerationTest;
 import org.openbravo.test.dal.OBContextTest;
 import org.openbravo.test.dal.ValidationTest;
@@ -79,7 +79,7 @@
     suite.addTestSuite(DalPerformanceProductTest.class);
     suite.addTestSuite(DalQueryTest.class);
     suite.addTestSuite(DalTest.class);
-    suite.addTestSuite(DalCopyTest.class);
+    suite.addTestSuite(IssuesTest.class);
     suite.addTestSuite(DalConnectionProviderTest.class);
     suite.addTestSuite(DynamicEntityTest.class);
     suite.addTestSuite(HiddenUpdateTest.class);
--- a/src-test/org/openbravo/test/AllTests.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-test/org/openbravo/test/AllTests.java	Thu Nov 26 16:35:30 2009 +0100
@@ -29,6 +29,7 @@
 import org.openbravo.test.dal.DalTest;
 import org.openbravo.test.dal.DynamicEntityTest;
 import org.openbravo.test.dal.HiddenUpdateTest;
+import org.openbravo.test.dal.IssuesTest;
 import org.openbravo.test.dal.MappingGenerationTest;
 import org.openbravo.test.dal.ValidationTest;
 import org.openbravo.test.expression.EvaluationTest;
@@ -65,6 +66,7 @@
     suite.addTestSuite(ValidationTest.class);
     suite.addTestSuite(DynamicEntityTest.class);
     suite.addTestSuite(DalTest.class);
+    suite.addTestSuite(IssuesTest.class);
     suite.addTestSuite(DalQueryTest.class);
     suite.addTestSuite(DalConnectionProviderTest.class);
     suite.addTestSuite(DalCopyTest.class);
--- a/src-test/org/openbravo/test/AntTaskTests.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-test/org/openbravo/test/AntTaskTests.java	Thu Nov 26 16:35:30 2009 +0100
@@ -33,6 +33,7 @@
 import org.openbravo.test.dal.DalTest;
 import org.openbravo.test.dal.DynamicEntityTest;
 import org.openbravo.test.dal.HiddenUpdateTest;
+import org.openbravo.test.dal.IssuesTest;
 import org.openbravo.test.dal.MappingGenerationTest;
 import org.openbravo.test.dal.OBContextTest;
 import org.openbravo.test.dal.ValidationTest;
@@ -85,6 +86,7 @@
     suite.addTestSuite(DalTest.class);
     suite.addTestSuite(DalCopyTest.class);
     suite.addTestSuite(DynamicEntityTest.class);
+    suite.addTestSuite(IssuesTest.class);
     suite.addTestSuite(HiddenUpdateTest.class);
     // suite.addTestSuite(HqlTest.class);
     suite.addTestSuite(MappingGenerationTest.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/dal/IssuesTest.java	Thu Nov 26 16:35:30 2009 +0100
@@ -0,0 +1,77 @@
+/*
+ *************************************************************************
+ * 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) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.dal;
+
+import org.openbravo.base.provider.OBProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.module.Module;
+import org.openbravo.model.ad.system.Language;
+import org.openbravo.model.ad.ui.Form;
+import org.openbravo.model.ad.ui.FormTrl;
+import org.openbravo.test.base.BaseTest;
+
+/**
+ * Tests the following issues:
+ * 
+ * - https://issues.openbravo.com/view.php?id=11461 When saving business object in S/C data level
+ * then access level exception is thrown for the child object
+ * 
+ * 
+ * @author mtaal
+ */
+
+public class IssuesTest extends BaseTest {
+
+  /**
+   * Tests issue: https://issues.openbravo.com/view.php?id=11461
+   */
+  public void test11461() {
+    setSystemAdministratorContext();
+
+    Module module = OBDal.getInstance().createCriteria(Module.class).list().get(0);
+    module.setInDevelopment(true);
+    OBDal.getInstance().save(module);
+    OBDal.getInstance().flush();
+
+    Form form = OBProvider.getInstance().get(Form.class);
+    form.setName("test");
+    form.setDataAccessLevel("1");
+    form.setDescription("description");
+    form.setHelpComment("help");
+    form.setModule(module);
+    form.setJavaClassName("test");
+
+    FormTrl formTrl = OBProvider.getInstance().get(FormTrl.class);
+    formTrl.setHelpComment("help");
+    formTrl.setDescription("description");
+    formTrl.setName("name");
+    formTrl.setSpecialForm(form);
+    formTrl.setLanguage(OBDal.getInstance().createCriteria(Language.class).list().get(0));
+
+    form.getADFormTrlList().add(formTrl);
+    OBDal.getInstance().save(form);
+    OBDal.getInstance().flush();
+
+    // if we get here then the issue is solved.
+
+    // don't save anything
+    OBDal.getInstance().rollbackAndClose();
+  }
+}
\ No newline at end of file
--- a/src-test/org/openbravo/test/system/SystemValidatorTest.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src-test/org/openbravo/test/system/SystemValidatorTest.java	Thu Nov 26 16:35:30 2009 +0100
@@ -28,6 +28,8 @@
 import org.apache.ddlutils.model.Database;
 import org.apache.log4j.Logger;
 import org.openbravo.base.session.OBPropertiesProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.module.Module;
 import org.openbravo.service.system.DatabaseValidator;
 import org.openbravo.service.system.ModuleValidator;
 import org.openbravo.service.system.SystemValidationResult;
@@ -55,7 +57,22 @@
     final DatabaseValidator databaseValidator = new DatabaseValidator();
     databaseValidator.setDatabase(createDatabaseObject());
     final SystemValidationResult result = databaseValidator.validate();
-    printResult(result);
+    printResult(result, true);
+  }
+
+  /**
+   * Executes the {@link DatabaseValidator#validate()} method on the current database for all
+   * modules.
+   */
+  public void testSystemValidationModules() {
+    setUserContext("0");
+    for (Module module : OBDal.getInstance().createQuery(Module.class, "").list()) {
+      final DatabaseValidator databaseValidator = new DatabaseValidator();
+      databaseValidator.setDatabase(createDatabaseObject());
+      databaseValidator.setValidateModule(module);
+      final SystemValidationResult result = databaseValidator.validate();
+      printResult(result, false);
+    }
   }
 
   private Database createDatabaseObject() {
@@ -82,10 +99,10 @@
     setUserContext("0");
     final ModuleValidator moduleValidator = new ModuleValidator();
     final SystemValidationResult result = moduleValidator.validate();
-    printResult(result);
+    printResult(result, true);
   }
 
-  private void printResult(SystemValidationResult result) {
+  private void printResult(SystemValidationResult result, boolean allowFail) {
     for (SystemValidationType validationType : result.getWarnings().keySet()) {
       log.debug("\n+++++++++++++++++++++++++++++++++++++++++++++++++++");
       log.debug("Warnings for Validation type: " + validationType);
@@ -108,7 +125,7 @@
           sb.append("\n");
         }
       }
-      if (errors.size() > 0) {
+      if (allowFail && errors.size() > 0) {
         fail(sb.toString());
       }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/webservice/PerformanceTest.java	Thu Nov 26 16:35:30 2009 +0100
@@ -0,0 +1,137 @@
+/*
+ *************************************************************************
+ * 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) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.webservice;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.test.base.BaseTest;
+
+/**
+ * Test class for reading large xml files from a webservice. Xml is streamed directly to a file.
+ * 
+ * NOTE: contains several hard-coded path (/tmp/test.xml) so is not for general usage in test
+ * suites.
+ * 
+ * @author mtaal
+ */
+
+public class PerformanceTest extends BaseTest {
+
+  private static final Logger log = Logger.getLogger(PerformanceTest.class);
+
+  private static final String OB_URL = "http://localhost:8080/openbravo";
+  private static final String LOGIN = "Openbravo";
+  private static final String PWD = "openbravo";
+
+  public void testPerformance() {
+    try {
+      final HttpURLConnection hc = createConnection(
+          "/ws/dal/BusinessPartner?includeChildren=false", "GET");
+      hc.connect();
+      final InputStream is = hc.getInputStream();
+      final OutputStream os = new FileOutputStream("/tmp/test.xml");
+      int totalRead = 0;
+      int cnt = 0;
+      while (true) {
+        final byte[] bytes = new byte[50000];
+        final int bytesRead = is.read(bytes);
+        if (bytesRead == -1) {
+          break;
+        }
+        os.write(bytes, 0, bytesRead);
+        totalRead += bytesRead;
+        if ((cnt++ % 100) == 0) {
+          System.err.println(totalRead);
+          os.flush();
+        }
+      }
+      os.close();
+    } catch (final Exception e) {
+      throw new OBException(e);
+    }
+  }
+
+  /**
+   * Creates a HTTP connection.
+   * 
+   * @param wsPart
+   * @param method
+   *          POST, PUT, GET or DELETE
+   * @return the created connection
+   * @throws Exception
+   */
+  protected HttpURLConnection createConnection(String wsPart, String method) throws Exception {
+    Authenticator.setDefault(new Authenticator() {
+      @Override
+      protected PasswordAuthentication getPasswordAuthentication() {
+        return new PasswordAuthentication(LOGIN, PWD.toCharArray());
+      }
+    });
+    log.debug(method + ": " + getOpenbravoURL() + wsPart);
+    final URL url = new URL(getOpenbravoURL() + wsPart);
+    final HttpURLConnection hc = (HttpURLConnection) url.openConnection();
+    hc.setRequestMethod(method);
+    hc.setAllowUserInteraction(false);
+    hc.setDefaultUseCaches(false);
+    hc.setDoOutput(true);
+    hc.setDoInput(true);
+    hc.setInstanceFollowRedirects(true);
+    hc.setUseCaches(false);
+    hc.setRequestProperty("Content-Type", "text/xml");
+    return hc;
+  }
+
+  /**
+   * Returns the url of the Openbravo instance. The default value is: {@link #OB_URL}
+   * 
+   * @return the url of the Openbravo instance.
+   */
+  protected String getOpenbravoURL() {
+    return OB_URL;
+  }
+
+  /**
+   * Returns the login used to login for the webservice. The default value is {@link #LOGIN}.
+   * 
+   * @return the login name used to login for the webservice
+   */
+  protected String getLogin() {
+    return LOGIN;
+  }
+
+  /**
+   * Returns the password used to login into the webservice server. The default value is
+   * {@link #PWD}.
+   * 
+   * @return the password used to login into the webservice, the default is {@link #PWD}
+   */
+  protected String getPassword() {
+    return PWD;
+  }
+
+}
\ No newline at end of file
--- a/src-wad/src/org/openbravo/wad/Imports_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- *************************************************************************
- * 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) 2001-2006 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
--->
-
-
-
-<SqlClass name="ImportsData" package="org.openbravo.wad">
-  <SqlMethod name="select" type="preparedStatement" return="multiple">
-    <SqlMethodComment>Imports needed in the servlet, actually none (1=0)</SqlMethodComment>
-    <Sql>
-      SELECT dummy as Name FROM DUAL WHERE 1=0
-    </Sql>
-  </SqlMethod>
-</SqlClass>
--- a/src/org/openbravo/base/expression/Evaluator.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/expression/Evaluator.java	Thu Nov 26 16:35:30 2009 +0100
@@ -39,14 +39,14 @@
 
   private static Evaluator instance = new Evaluator();
 
-  public static Evaluator getInstance() {
+  public static synchronized Evaluator getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(Evaluator.class);
     }
     return instance;
   }
 
-  public static void setInstance(Evaluator instance) {
+  public static synchronized void setInstance(Evaluator instance) {
     Evaluator.instance = instance;
   }
 
--- a/src/org/openbravo/base/model/ModelProvider.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/model/ModelProvider.java	Thu Nov 26 16:35:30 2009 +0100
@@ -78,7 +78,7 @@
    * 
    * @return the ModelProvider instance
    */
-  public static ModelProvider getInstance() {
+  public static synchronized ModelProvider getInstance() {
     // set in a localInstance to prevent threading issues when
     // reseting it in setInstance()
     ModelProvider localInstance = instance;
@@ -95,7 +95,7 @@
    * @param instance
    *          the custom ModelProvider
    */
-  public static void setInstance(ModelProvider instance) {
+  public static synchronized void setInstance(ModelProvider instance) {
     ModelProvider.instance = instance;
   }
 
--- a/src/org/openbravo/base/model/NamingUtil.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/model/NamingUtil.java	Thu Nov 26 16:35:30 2009 +0100
@@ -97,6 +97,45 @@
   }
 
   /**
+   * Checks if a name of a table contains illegal chars.
+   * 
+   * @param name
+   *          the name to check
+   * @return true if the name contains a char from the {@link #ILLEGAL_ENTITY_NAME_CHARS}).
+   */
+  public static boolean doesNameHaveIllegalChars(String name) {
+    final char[] chars = name.trim().toCharArray();
+    for (char c : chars) {
+      for (char illegalChar : ILLEGAL_ENTITY_NAME_CHARS) {
+        if (c == illegalChar) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  /**
+   * Checks a name for non-normal characters. Non-normal is everything from a to z, A to Z, 0 to 9
+   * and _.
+   * 
+   * @param name
+   *          the name to check
+   * @return true if the name contains illegal chars, false otherwise
+   */
+  public static boolean doesNameContainNonNormalCharacters(String name) {
+    final char[] chars = name.trim().toCharArray();
+    for (char c : chars) {
+      final boolean normalChar = ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9')
+          || ('a' <= c && c <= 'z') || c == '_';
+      if (!normalChar) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  /**
    * Returns the value of the ENTITY_NAME constant in the passed class.
    * 
    * @param clz
--- a/src/org/openbravo/base/provider/OBConfigFileProvider.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/provider/OBConfigFileProvider.java	Thu Nov 26 16:35:30 2009 +0100
@@ -41,14 +41,14 @@
 
   private static OBConfigFileProvider instance;
 
-  public static OBConfigFileProvider getInstance() {
+  public static synchronized OBConfigFileProvider getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(OBConfigFileProvider.class);
     }
     return instance;
   }
 
-  public static void setInstance(OBConfigFileProvider instance) {
+  public static synchronized void setInstance(OBConfigFileProvider instance) {
     OBConfigFileProvider.instance = instance;
   }
 
--- a/src/org/openbravo/base/provider/OBProvider.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/provider/OBProvider.java	Thu Nov 26 16:35:30 2009 +0100
@@ -20,7 +20,7 @@
 package org.openbravo.base.provider;
 
 import java.io.InputStream;
-import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
@@ -51,7 +51,7 @@
     OBProvider.instance = instance;
   }
 
-  private Map<String, Registration> registrations = new HashMap<String, Registration>();
+  private Map<String, Registration> registrations = new Hashtable<String, Registration>();
 
   /**
    * Returns true if the clz is registered.
--- a/src/org/openbravo/base/secureApp/Seguridad_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/secureApp/Seguridad_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -44,10 +44,6 @@
       <Parameter name="user"/>
       <Parameter name="passwd"/>
    </SqlMethod>
-   <SqlMethod name="autentificado" type="preparedStatement" return="boolean">
-      <SqlMethodComment></SqlMethodComment>
-      <Sql>SELECT 1 FROM DUAL</Sql>
-   </SqlMethod>
    <SqlMethod name="loggedOK" type="preparedStatement" return="boolean">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
@@ -58,12 +54,6 @@
       </Sql>
       <Parameter name="adSessionId"/>
    </SqlMethod>
-   <SqlMethod name="autorizado" type="preparedStatement" return="boolean">
-      <SqlMethodComment></SqlMethodComment>
-      <Sql>
-        SELECT 1 FROM DUAL
-      </Sql>
-   </SqlMethod>
 
    <SqlMethod name="isUserRole" type="preparedStatement" return="Boolean" default="false">
       <SqlMethodComment></SqlMethodComment>
--- a/src/org/openbravo/base/session/OBPropertiesProvider.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/session/OBPropertiesProvider.java	Thu Nov 26 16:35:30 2009 +0100
@@ -40,11 +40,11 @@
 
   private static OBPropertiesProvider instance = new OBPropertiesProvider();
 
-  public static OBPropertiesProvider getInstance() {
+  public static synchronized OBPropertiesProvider getInstance() {
     return instance;
   }
 
-  public static void setInstance(OBPropertiesProvider instance) {
+  public static synchronized void setInstance(OBPropertiesProvider instance) {
     OBPropertiesProvider.instance = instance;
   }
 
--- a/src/org/openbravo/base/session/SessionFactoryController.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/session/SessionFactoryController.java	Thu Nov 26 16:35:30 2009 +0100
@@ -76,11 +76,11 @@
     SessionFactoryController.runningInWebContainer = runningInWebContainer;
   }
 
-  public static SessionFactoryController getInstance() {
+  public static synchronized SessionFactoryController getInstance() {
     return instance;
   }
 
-  public static void setInstance(SessionFactoryController sfc) {
+  public static synchronized void setInstance(SessionFactoryController sfc) {
     if (sfc != null) {
       log.debug("Setting instance of " + sfc.getClass().getName()
           + " as session factory controller");
--- a/src/org/openbravo/base/structure/IdentifierProvider.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/base/structure/IdentifierProvider.java	Thu Nov 26 16:35:30 2009 +0100
@@ -41,14 +41,14 @@
 
   private static IdentifierProvider instance;
 
-  public static IdentifierProvider getInstance() {
+  public static synchronized IdentifierProvider getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(IdentifierProvider.class);
     }
     return instance;
   }
 
-  public static void setInstance(IdentifierProvider instance) {
+  public static synchronized void setInstance(IdentifierProvider instance) {
     IdentifierProvider.instance = instance;
   }
 
--- a/src/org/openbravo/dal/core/DalMappingGenerator.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/dal/core/DalMappingGenerator.java	Thu Nov 26 16:35:30 2009 +0100
@@ -54,14 +54,14 @@
 
   private static DalMappingGenerator instance = new DalMappingGenerator();
 
-  public static DalMappingGenerator getInstance() {
+  public static synchronized DalMappingGenerator getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(DalMappingGenerator.class);
     }
     return instance;
   }
 
-  public static void setInstance(DalMappingGenerator dalMappingGenerator) {
+  public static synchronized void setInstance(DalMappingGenerator dalMappingGenerator) {
     instance = dalMappingGenerator;
   }
 
--- a/src/org/openbravo/dal/core/OBInterceptor.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/dal/core/OBInterceptor.java	Thu Nov 26 16:35:30 2009 +0100
@@ -151,7 +151,8 @@
 
     checkReferencedOrganizations(entity, currentState, previousState, propertyNames);
 
-    if (entity instanceof Traceable) {
+    if (entity instanceof Traceable || entity instanceof ClientEnabled
+        || entity instanceof OrganizationEnabled) {
       return true;
     }
     return false;
@@ -204,8 +205,7 @@
     boolean isNew = bob.getId() == null || bob.isNewOBObject();
 
     // check if the organization of the current object has changed, if so
-    // then
-    // check all references
+    // then check all references
     if (!isNew) {
       for (int i = 0; i < currentState.length; i++) {
         if (propertyNames[i].equals(PROPERTY_ORGANIZATION)) {
@@ -241,19 +241,19 @@
   }
 
   // general event handler does new and update
-  protected void doEvent(Object o, Object[] currentState, String[] propertyNames) {
+  protected void doEvent(Object object, Object[] currentState, String[] propertyNames) {
     try {
       // not traceable but still do the security check
-      if (!(o instanceof Traceable)) {
+      if (!(object instanceof Traceable)) {
         // do a check for writeaccess
         // TODO: the question is if this is the correct
         // location as because of hibernate cascade many things are
         // written.
-        SecurityChecker.getInstance().checkWriteAccess(o);
+        SecurityChecker.getInstance().checkWriteAccess(object);
         return;
       }
 
-      final Traceable t = (Traceable) o;
+      final Traceable t = (Traceable) object;
       if (t.getCreatedBy() == null) { // new
         onNew(t, propertyNames, currentState);
       } else {
@@ -269,46 +269,58 @@
     // do a check for writeaccess
     // TODO: the question is if this is the correct
     // location as because of hibernate cascade many things are written.
-    SecurityChecker.getInstance().checkWriteAccess(o);
+    SecurityChecker.getInstance().checkWriteAccess(object);
   }
 
   // set created/createdby and the client and organization
-  private void onNew(Traceable t, String[] propertyNames, Object[] currentState) {
+  private void onNew(Traceable traceable, String[] propertyNames, Object[] currentState) {
+    // note both the currentState and the Traceable t are modified
+    // the object t is modified because right after this call a security
+    // check is done (see onSave). This is before hibernate can copy
+    // the changes from currentState to the object. This happens slighlty later.
     final OBContext obContext = OBContext.getOBContext();
     final User currentUser = obContext.getUser();
-    log
-        .debug("OBEvent for new object " + t.getClass().getName() + " user "
-            + currentUser.getName());
+    log.debug("OBEvent for new object " + traceable.getClass().getName() + " user "
+        + currentUser.getName());
 
     Client client = null;
     Organization org = null;
-    if (t instanceof ClientEnabled || t instanceof OrganizationEnabled) {
+    if (traceable instanceof ClientEnabled || traceable instanceof OrganizationEnabled) {
       // reread the client and organization
       client = SessionHandler.getInstance()
           .find(Client.class, obContext.getCurrentClient().getId());
       org = SessionHandler.getInstance().find(Organization.class,
           obContext.getCurrentOrganization().getId());
     }
+    final Date currentDate = new Date();
     for (int i = 0; i < propertyNames.length; i++) {
+      // TODO: check why this is here, seems strange
       if ("".equals(propertyNames[i])) {
-        currentState[i] = new Date();
+        currentState[i] = currentDate;
       }
+
       if (PROPERTY_UPDATED.equals(propertyNames[i])) {
-        currentState[i] = new Date();
+        traceable.setUpdated(currentDate);
+        currentState[i] = currentDate;
       }
       if (PROPERTY_UPDATEDBY.equals(propertyNames[i])) {
+        traceable.setUpdatedBy(currentUser);
         currentState[i] = currentUser;
       }
       if (Organization.PROPERTY_CREATIONDATE.equals(propertyNames[i])) {
-        currentState[i] = new Date();
+        traceable.setCreationDate(currentDate);
+        currentState[i] = currentDate;
       }
       if (Organization.PROPERTY_CREATEDBY.equals(propertyNames[i])) {
+        traceable.setCreatedBy(currentUser);
         currentState[i] = currentUser;
       }
       if (PROPERTY_CLIENT.equals(propertyNames[i]) && currentState[i] == null) {
+        ((ClientEnabled) traceable).setClient(client);
         currentState[i] = client;
       }
       if (PROPERTY_ORGANIZATION.equals(propertyNames[i]) && currentState[i] == null) {
+        ((OrganizationEnabled) traceable).setOrganization(org);
         currentState[i] = org;
       }
     }
@@ -331,6 +343,7 @@
   }
 
   // after flushing an object is not new anymore
+  @SuppressWarnings("unchecked")
   public void postFlush(Iterator entities) {
     while (entities.hasNext()) {
       final BaseOBObject bob = (BaseOBObject) entities.next();
--- a/src/org/openbravo/dal/xml/PrimitiveReferenceHandler.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/dal/xml/PrimitiveReferenceHandler.java	Thu Nov 26 16:35:30 2009 +0100
@@ -63,14 +63,14 @@
 
   private static PrimitiveReferenceHandler instance;
 
-  public static PrimitiveReferenceHandler getInstance() {
+  public static synchronized PrimitiveReferenceHandler getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(PrimitiveReferenceHandler.class);
     }
     return instance;
   }
 
-  public static void setInstance(PrimitiveReferenceHandler instance) {
+  public static synchronized void setInstance(PrimitiveReferenceHandler instance) {
     PrimitiveReferenceHandler.instance = instance;
   }
 
--- a/src/org/openbravo/dal/xml/XMLTypeConverter.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/dal/xml/XMLTypeConverter.java	Thu Nov 26 16:35:30 2009 +0100
@@ -40,14 +40,14 @@
 
   private static XMLTypeConverter instance = new XMLTypeConverter();
 
-  public static XMLTypeConverter getInstance() {
+  public static synchronized XMLTypeConverter getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(XMLTypeConverter.class);
     }
     return instance;
   }
 
-  public static void setInstance(XMLTypeConverter instance) {
+  public static synchronized void setInstance(XMLTypeConverter instance) {
     XMLTypeConverter.instance = instance;
   }
 
--- a/src/org/openbravo/dal/xml/XMLUtil.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/dal/xml/XMLUtil.java	Thu Nov 26 16:35:30 2009 +0100
@@ -46,14 +46,14 @@
 
   private static XMLUtil instance;
 
-  public static XMLUtil getInstance() {
+  public static synchronized XMLUtil getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(XMLUtil.class);
     }
     return instance;
   }
 
-  public static void setInstance(XMLUtil instance) {
+  public static synchronized void setInstance(XMLUtil instance) {
     XMLUtil.instance = instance;
   }
 
--- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromSettlement.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromSettlement.java	Thu Nov 26 16:35:30 2009 +0100
@@ -106,6 +106,8 @@
     String strHaber = "";
     String strImporte = "";
     String strCBPartnerId_D = "";
+    String spChars = "";
+    boolean inpEvent = false;
     try {
       conn = getTransactionConnection();
       CopyFromSettlementData[] data = CopyFromSettlementData.select(this, strKey);
@@ -120,7 +122,30 @@
           strCBPartnerId = "";
         }
         strDate = vars.getStringParameter("inpDate" + data[i].cDebtPaymentId);
+        if (strDate.equals("")) {
+          myError = Utility.translateError(this, vars, vars.getLanguage(),
+              "The field DatePlanned is mandatory and cannot be left empty");
+          return myError;
+        }
         strImporte = vars.getStringParameter("inpAmount" + data[i].cDebtPaymentId);
+        if (strImporte.equals("")) {
+          myError = Utility.translateError(this, vars, vars.getLanguage(),
+              "The field Amount is mandatory and cannot be left empty");
+          return myError;
+        }
+        spChars = " `()\\~!@^&*+\"|:=,< >$-%/;'";
+        int pos;
+        for (int a = 1; a <= 25; a++) {
+          pos = strImporte.indexOf(spChars.charAt(a));
+          if (pos != -1) {
+            inpEvent = true;
+          }
+        }
+        if (inpEvent == true) {
+          myError = Utility.translateError(this, vars, vars.getLanguage(),
+              "The number is not correct.You may check the data");
+          return myError;
+        }
         try {
           CopyFromSettlementData.insertDebtPayment(conn, this, strDebtPayment, to[0].client,
               to[0].org, vars.getUser(), data[i].isreceipt, strSettlement, data[i].description,
@@ -134,7 +159,17 @@
         }
         for (int j = 0; j < data1.length; j++) {
           strDebe = vars.getStringParameter("inpDebe" + data1[j].cDebtPaymentBalancingId);
+          if (strDebe.equals("")) {
+            myError = Utility.translateError(this, vars, vars.getLanguage(),
+                "The field Debit is mandatory and cannot be left empty");
+            return myError;
+          }
           strHaber = vars.getStringParameter("inpHaber" + data1[j].cDebtPaymentBalancingId);
+          if (strHaber.equals("")) {
+            myError = Utility.translateError(this, vars, vars.getLanguage(),
+                "The field Credit is mandatory and cannot be left empty");
+            return myError;
+          }
           strDebtPaymentBalancing = SequenceIdData.getUUID();
           try {
             CopyFromSettlementData.insert(conn, this, strDebtPaymentBalancing, to[0].client,
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_ShipmentPO.html	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_ShipmentPO.html	Thu Nov 26 16:35:30 2009 +0100
@@ -109,9 +109,9 @@
   else if (!chk.length){
 	  chk.checked = bolCheck;
 	  var frm = document.frmMain;
-	  frm.elements["inpmovementqty" + chk[i].value].disabled=!bolCheck; 
-	  frm.elements["inpquantityorder" + chk[i].value].disabled=!bolCheck;
-	  frm.elements["inpmProductUomId" + chk[i].value].disabled=!bolCheck;
+	  frm.elements["inpmovementqty" + chk.value].disabled=!bolCheck; 
+	  frm.elements["inpquantityorder" + chk.value].disabled=!bolCheck;
+	  frm.elements["inpmProductUomId" + chk.value].disabled=!bolCheck;
   }
   else {
     var total = chk.length;
--- a/src/org/openbravo/erpCommon/ad_actionButton/DropRegFactAcct_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/DropRegFactAcct_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SL
- * All portions are Copyright (C) 2001-2006 Openbravo SL
+ * All portions are Copyright (C) 2001-2009 Openbravo SL
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -37,16 +37,6 @@
     <Parameter name="adlanguage"/>
     <Parameter name="cYearId"/>
   </SqlMethod>
-  <SqlMethod name="deleteOrgAcctschema" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-	  DELETE AD_ORG_ACCTSCHEMA
-	  WHERE AD_ORG_ACCTSCHEMA_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="adOrgAcctschemaId"/>
-  </SqlMethod>
   <SqlMethod name="updatePeriodsOpen" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
--- a/src/org/openbravo/erpCommon/ad_actionButton/TaxRegister.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/TaxRegister.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -22,19 +22,6 @@
 
 <SqlClass name="TaxRegister" package="org.openbravo.erpCommon.ad_actionButton">
 
-  <SqlMethod name="select" type="preparedStatement" return="multiple">
-  <SqlMethodComment>Active Tax Register </SqlMethodComment>
-  <Sql>
-  <![CDATA[
-        SELECT AD_Client_ID, AD_Org_ID, C_TaxRegister_ID,  C_TaxPayment_ID, LastRegAccumAmt , TaxTotalAmt , C_TaxRegister_Type_ID, Name ,PageNo  
-			FROM C_TAXREGISTER
-			WHERE ISACTIVE='Y'
-			And C_TaxRegister_ID = ?
-      ]]>
-  </Sql>
-  <Parameter name="taxregister_id"/>
-  </SqlMethod>
- 
   <SqlMethod name="selectChild" type="preparedStatement" return="multiple">
   <SqlMethodComment>Active Tax Register </SqlMethodComment>
   <Sql>
@@ -122,29 +109,6 @@
   <Parameter name="taxregister_id"/>
   </SqlMethod>
 
-<SqlMethod name="updateLastRegAccumAmt" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Update Tax Register Totals</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  	   UPDATE C_TAXREGISTER 
-  	   SET LASTREGACCUMAMT =
-  	   (SELECT TAXTOTALAMT FROM C_TAXREGISTER WHERE C_TAXREGISTER_ID=
-  	   (SELECT MAX(C_TAXREGISTER_ID) FROM C_TAXREGISTER, C_TAXPAYMENT
-  	   WHERE C_TAXREGISTER_ID <> ?
-  	   AND C_TAXREGISTER_TYPE_ID = ?
-  	   AND C_TAXREGISTER.C_TAXPAYMENT_ID=C_TAXPAYMENT.C_TAXPAYMENT_ID
-  	   AND C_TAXPAYMENT.DATETO = TO_DATE( ? )-1
-  	   AND C_TAXPAYMENT.PROCESSED='Y')) 
-  	   WHERE C_TAXREGISTER_id = ?		
-      ]]>
-  </Sql>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxregistertype_id"/>
-  <Parameter name="datefrom"/>
-  <Parameter name="taxregister_id"/>
-  
-  </SqlMethod>
-  
   <SqlMethod name="updateRegAccumAmt" type="preparedStatement" return="rowcount">
   <SqlMethodComment>Update Tax Register Totals</SqlMethodComment>
   <Sql>
@@ -185,35 +149,4 @@
   
   </SqlMethod>
   
-  <SqlMethod name="selectPageNoPrior" type="preparedStatement" return="string">
-  <SqlMethodComment>select PageNo Prior Period</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  select coalesce(max(taxreg.pageno),0) 
-  from c_taxregister taxreg,c_taxpayment taxpay 
-  where 
-  	  taxpay.c_taxpayment_id = taxreg.c_taxpayment_id
-  and to_char(taxpay.datefrom,'YYYY') = to_char(now(),'YYYY')
-  and ( taxpay.processed = 'Y' or taxpay.c_taxpayment_id=
-  (select c_taxpayment_id from c_taxregister where c_taxregister_id = ? ) )
-  and 1=1	
-      ]]>
-  </Sql>
-  <Parameter name="parTaxRegId"/>
-  <Parameter name="parTaxRegId" optional="false" after="and 1=1"><![CDATA[ and taxreg.c_taxregister_id <> ?  ]]></Parameter>
-  </SqlMethod>
-  
-  <SqlMethod name="updatePageNo" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Update Page No</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  		update c_taxregister
-  		set pageno= ? 
-  		where c_taxregister_id = ?  
-      ]]>
-  </Sql>
-  <Parameter name="pageno"/>
-  <Parameter name="taxregister_id"/>
-  </SqlMethod>
-
 </SqlClass>
--- a/src/org/openbravo/erpCommon/ad_actionButton/Test_In_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/Test_In_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2008 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -35,7 +35,7 @@
       <SqlMethodComment></SqlMethodComment>
       <Sql>
         INSERT INTO AT_Line (AT_Line_ID, AD_Client_ID, AD_Org_ID, Isactive, Created, Createdby, Updated, Updatedby, AT_Test_ID, AT_Command_ID, Seqno, Arg1, Arg2, Arg3, Type, Argno, Arghelp1, Arghelp2, Arghelp3, child_test)
-        VALUES ( ?,?,?,'Y',now(),?,now(),?,?,?,?,?,?,?,?,?,?,?,?,'')
+        VALUES ( ?,?,?,'Y',now(),?,now(),?,?,?,TO_NUMBER(?),?,?,?,?,TO_NUMBER(?),?,?,?,'')
       </Sql>
       <Parameter name="AT_Line_ID"/>
       <Parameter name="AD_Client_ID"/>
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Thu Nov 26 16:35:30 2009 +0100
@@ -291,13 +291,15 @@
         if (!post(data[i].getField("ID"), false, vars, connectionProvider, con)) {
           connectionProvider.releaseRollbackConnection(con);
           return;
+        } else {
+          connectionProvider.releaseCommitConnection(con);
+          con = connectionProvider.getTransactionConnection();
         }
       }
       if (log4j.isDebugEnabled())
         log4j.debug("AcctServer - Run -" + data.length + " IDs [" + strIDs + "]");
       // Create Automatic Matching
       // match (vars, this,con);
-      connectionProvider.releaseCommitConnection(con);
     } catch (NoConnectionAvailableException ex) {
       throw new ServletException("@CODE=NoConnectionAvailable", ex);
     } catch (SQLException ex2) {
@@ -680,9 +682,6 @@
     int no = 0;
     try {
       no = AcctServerData.updateSave(conn, tableName, Status, Record_ID);
-      // If Status is not posted (Error...) then the created accounting is deleted
-      if (!Status.equals(AcctServer.STATUS_Posted))
-        AcctServerData.delete(connectionProvider, AD_Table_ID, Record_ID);
     } catch (ServletException e) {
       log4j.warn(e);
     }
--- a/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -27,18 +27,7 @@
       ]]>
     </Sql>
   </SqlMethod>
-  <SqlMethod name="selectTables" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-    select ad_table_id as id from ad_table where tablename in ('C_Invoice','C_BankStatement','C_Cash','GL_Journal','C_Settlement')
-      ]]>
-    </Sql>
-  </SqlMethod>
-     <SqlMethod name="set" type="constant" return="multiple">
-      <SqlMethodComment></SqlMethodComment>
-      <Sql></Sql>
-   </SqlMethod>
+
   <SqlMethod name="insertClient" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -119,19 +108,7 @@
     <Parameter name="AD_Tree_SalesRegion_ID"/>
     <Parameter name="AD_Tree_Product_ID"/>
   </SqlMethod>
-    <SqlMethod name="insertOrg" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO AD_Org (AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,IsSummary)
-      VALUES (?,?,'Y',now(),'0',now(),'0' ,?,?,'N')
-      ]]>
-    </Sql>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_Org_ID"/>
-    <Parameter name="name"/>
-    <Parameter name="name"/>
-  </SqlMethod>
+
     <SqlMethod name="insertRole" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -148,22 +125,7 @@
     <Parameter name="AD_Client_ID"/>
     <Parameter name="AD_Org_ID"/>
   </SqlMethod>
-    <SqlMethod name="insertRole2" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO AD_Role(AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Role_ID,Name,
-      Description,UserLevel,ClientList,OrgList)
-      VALUES (?,'0','Y',now(),'0',now(),'0',?,?,?,'  O',?,?)
-      ]]>
-    </Sql>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_Role_ID_U"/>
-    <Parameter name="name"/>
-    <Parameter name="name"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_Org_ID"/>
-  </SqlMethod>
+
       <SqlMethod name="insertRoleOrgAccess" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -302,18 +264,7 @@
     <Parameter name="C_Element_ID"/>
     <Parameter name="C_AcctSchema_Element_ID"/>
   </SqlMethod>
-      <SqlMethod name="updateAcctSchemaElement3" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      UPDATE C_AcctSchema_Element SET C_Project_ID = ?
-      WHERE C_AcctSchema_ID = ?
-      AND ElementType='PJ'
-      ]]>
-    </Sql>
-    <Parameter name="C_Project_ID"/>
-    <Parameter name="C_AcctSchema_ID"/>
-  </SqlMethod>
+
       <SqlMethod name="insertAcctSchemaGL" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -598,194 +549,7 @@
     </Sql>
     <Parameter name="currency"/>
   </SqlMethod>
-  <SqlMethod name="insertChannel" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO C_Channel (C_Channel_ID,Name,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy)
-      VALUES (?,?,?,'0','Y',now(),'0',now(),'0')
-      ]]>
-    </Sql>
-    <Parameter name="C_Channel_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="AD_Client_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertCampaign" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO C_Campaign (C_Campaign_ID,C_Channel_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,Costs)
-      VALUES (?,?,?,'0','Y',now(),'0',now(),'0',?,?,'0')
-      ]]>
-    </Sql>
-    <Parameter name="C_Campaign_ID"/>
-    <Parameter name="C_Channel_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
-  <SqlMethod name="updateAcctSchemaElementSR" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE C_AcctSchema_Element
-      SET C_SalesRegion_ID = ?
-      WHERE C_AcctSchema_ID= ?
-      AND ElementType='SR'
-    </Sql>
-    <Parameter name="C_SalesRegion_ID"/>
-    <Parameter name="C_AcctSchema_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateAcctSchemaElementMC" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE C_AcctSchema_Element
-      SET C_Campaign_ID = ?
-      WHERE C_AcctSchema_ID= ?
-      AND ElementType='MC'
-    </Sql>
-    <Parameter name="C_Campaign_ID"/>
-    <Parameter name="C_AcctSchema_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateAcctSchemaElementBP" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE C_AcctSchema_Element
-      SET C_BPartner_ID = ?
-      WHERE C_AcctSchema_ID= ?
-      AND ElementType='BP'
-    </Sql>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="C_AcctSchema_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateAcctSchemaElementPR" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE C_AcctSchema_Element
-      SET M_Product_ID = ?
-      WHERE C_AcctSchema_ID= ?
-      AND ElementType='PR'
-    </Sql>
-    <Parameter name="M_Product_ID"/>
-    <Parameter name="C_AcctSchema_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertSalesRegion" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_SalesRegion (C_SalesRegion_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,IsSummary)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,'N')
-    </Sql>
-    <Parameter name="C_SalesRegion_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
 
-  <SqlMethod name="insertAssetGroup" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO A_Asset_Group (A_ASSET_GROUP_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, NAME)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?)
-    </Sql>
-    <Parameter name="A_Asset_Group_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPGroup" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_BP_Group (C_BP_Group_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,'Y')
-    </Sql>
-    <Parameter name="C_BP_Group_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
-
-
-
-  <SqlMethod name="insertBPartner" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_BPartner
-         (C_BPartner_ID,AD_Client_ID,AD_Org_ID,IsActive,
-         Created,CreatedBy,Updated,UpdatedBy,
-         Value,Name,C_BP_Group_ID,IsSummary)
-      VALUES (?,?,'0','Y',
-              now(),'0',now(),'0',
-              ?,?,?,'N')
-    </Sql>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_BP_Group_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertProductCategory" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_Product_Category (M_Product_Category_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,IsDefault,PlannedMargin)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,'Y',0)
-    </Sql>
-    <Parameter name="M_Product_Category_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
-  <SqlMethod name="insertTaxCategory" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_TaxCategory (C_TaxCategory_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?, 'Y')
-    </Sql>
-    <Parameter name="C_TaxCategory_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="append"/>
-  </SqlMethod>
-  <SqlMethod name="insertTax" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_Tax (C_Tax_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-      Name,Rate,C_TaxCategory_ID,C_Country_ID,TO_Country_ID,
-      ValidFrom,SoPoType,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,0,?,?,?,TO_DATE('1990-01-01','YYYY-MM-DD'),'B','Y')
-    </Sql>
-    <Parameter name="C_Tax_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_TaxCategory_ID"/>
-    <Parameter name="C_Country_ID"/>
-    <Parameter name="C_Country_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertProduct" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_Product (M_Product_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-      Value,Name,C_UOM_ID,M_Product_Category_ID,C_TaxCategory_ID)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,?,?,?)
-    </Sql>
-    <Parameter name="M_Product_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_UOM_ID"/>
-    <Parameter name="M_Product_Category_ID"/>
-    <Parameter name="C_TaxCategory_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertLocation" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_Location (C_Location_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,City,
-      C_Country_ID,C_Region_ID)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,?)
-    </Sql>
-    <Parameter name="C_Location_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="City"/>
-    <Parameter name="C_Country_ID"/>
-    <Parameter name="C_Region_ID"/>
-  </SqlMethod>
   <SqlMethod name="updateOrgInfo" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -795,200 +559,6 @@
     <Parameter name="C_Location_ID"/>
     <Parameter name="AD_Org_ID"/>
   </SqlMethod>
-  <SqlMethod name="insertWarehouse" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-    INSERT INTO M_Warehouse (M_Warehouse_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-    Value,Name,C_Location_ID,Separator)
-    VALUES (?,?,?,'Y',now(),'0',now(),'0',?,?,?,'-')
-    </Sql>
-  <Parameter name="M_Warehouse_ID"/>
-  <Parameter name="AD_Client_ID"/>
-  <Parameter name="AD_Org_ID"/>
-  <Parameter name="defaultName"/>
-  <Parameter name="defaultName"/>
-  <Parameter name="C_Location_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertLocator" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_Locator (M_Locator_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,
-      Updated,UpdatedBy,Value,M_Warehouse_ID,X,Y,Z,PriorityNo,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),0,?,?,0,0,0,50,'Y')
-    </Sql>
-    <Parameter name="M_Locator_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="M_Warehouse_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateClientInfo2" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE AD_ClientInfo
-      SET C_BPartnerCashTrx_ID = ?, M_ProductFreight_ID = ?
-      WHERE AD_Client_ID = ?
-    </Sql>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="M_Product_ID"/>
-    <Parameter name="AD_Client_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertPriceList" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_PriceList (M_PriceList_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,
-      CreatedBy,Updated,UpdatedBy,Name,C_Currency_ID,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,'Y')
-    </Sql>
-    <Parameter name="M_PriceList_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_Currency_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertDiscountSchema" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_DiscountSchema (M_DiscountSchema_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,
-      Updated,UpdatedBy,Name,ValidFrom,DiscountType, FlatDiscount)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,now(),'P',0)
-    </Sql>
-    <Parameter name="M_DiscountSchema_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-  </SqlMethod>
-  <SqlMethod name="insertPriceListVersion" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_PriceList_Version (M_PriceList_Version_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,
-      UpdatedBy,Name,ValidFrom,M_PriceList_ID,M_DiscountSchema_ID)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,TO_DATE(now()),?,?)
-    </Sql>
-    <Parameter name="M_PriceList_Version_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="StringDate"/>
-    <Parameter name="M_PriceList_ID"/>
-    <Parameter name="M_DiscountSchema_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertProductPrice" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO M_ProductPrice (M_ProductPrice_ID, M_PriceList_Version_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,
-      UpdatedBy,M_Product_ID,PriceList,PriceStd,PriceLimit)
-      VALUES (get_uuid(), ?,?,'0','Y',now(),'0',now(),'0',?,1,1,1)
-    </Sql>
-    <Parameter name="M_PriceList_Version_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="M_Product_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertBPartnerLocation" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_BPartner_Location (C_BPartner_Location_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,
-      UpdatedBy,Name,C_BPartner_ID,C_Location_ID)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,?)
-    </Sql>
-    <Parameter name="C_BPartner_Location_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="City"/>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="C_Location_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertBPartner2" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_BPartner
-        (C_BPartner_ID,AD_Client_ID,AD_Org_ID,IsActive,
-        Created,CreatedBy,Updated, UpdatedBy,
-        Value,Name,C_BP_Group_ID,IsSummary,
-        IsEmployee,IsSalesRep,IsVendor)
-      VALUES (?,?,'0','Y',
-              now(),'0',now(),'0',
-              ?,?,?,'N',
-              'Y','Y','Y')
-    </Sql>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_User_U_Name"/>
-    <Parameter name="AD_User_U_Name"/>
-    <Parameter name="C_BP_Group_ID"/>
-  </SqlMethod>
-  <SqlMethod name="updateUser" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      UPDATE AD_User SET C_BPartner_ID = ?
-      WHERE AD_User_ID = ?
-    </Sql>
-    <Parameter name="C_BPartner_ID"/>
-    <Parameter name="AD_User_U_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertPaymentTerm" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_PaymentTerm (C_PaymentTerm_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,
-      CreatedBy,Updated,UpdatedBy,Value,Name,NetDays,IsDefault)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0','Immediate','Immediate',0,'Y')
-    </Sql>
-    <Parameter name="C_PaymentTerm_ID"/>
-    <Parameter name="AD_Client_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertCycle" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_Cycle (C_Cycle_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,C_Currency_ID)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?)
-    </Sql>
-    <Parameter name="C_Cycle_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_Currency_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertCycleStep" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_CycleStep (C_CycleStep_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-      C_Cycle_ID,SeqNo,C_ProjectStatus_ID,RelativeWeight)
-      VALUES (?,?,'0','Y',now(),'0',now(),'0',?,?,?,1)
-    </Sql>
-    <Parameter name="C_CycleStep_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="C_Cycle_ID"/>
-    <Parameter name="SeqNo"/>
-    <Parameter name="C_ProjectStatus_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertProject" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_Project (C_Project_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,
-      UpdatedBy,Value,Name,C_Currency_ID,IsSummary)
-      VALUES (?,?,?,'Y',now(),'0',now(),'0',?,?,?,'N')
-    </Sql>
-    <Parameter name="C_Project_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_Org_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_Currency_ID"/>
-  </SqlMethod>
-  <SqlMethod name="insertCashBook" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      INSERT INTO C_CashBook (C_CashBook_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,
-      Updated,UpdatedBy,Name,C_Currency_ID)
-      VALUES (?,?,?,'Y',now(),'0',now(),'0',?,?)
-    </Sql>
-    <Parameter name="C_CashBook_ID"/>
-    <Parameter name="AD_Client_ID"/>
-    <Parameter name="AD_Org_ID"/>
-    <Parameter name="defaultName"/>
-    <Parameter name="C_Currency_ID"/>
-  </SqlMethod>
-   <!--SqlMethod name="setup" type="callableStatement" return="object" object="InitialClientSetupData">
-      <SqlMethodComment></SqlMethodComment>
-      <Sql>
-        CALL AD_Setup(?,?)
-      </Sql>
-      <Parameter name="uno"/>
-      <Parameter name="dos"/>
-   </SqlMethod-->
    
    <SqlMethod name="selectCOAModules" type="preparedStatement" return="multiple">
     <SqlMethodComment>selects chart of accounts modules</SqlMethodComment>
@@ -1045,26 +615,6 @@
     <Parameter name="AD_Module_ID"/>
     <Parameter name="version"/>
   </SqlMethod>
-  <SqlMethod name="insertDoctypeTemplate" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO c_poc_doctype_template(
-            c_poc_doctype_template_id, ad_client_id, ad_org_id, isactive, 
-            created, createdby, updated, updatedby, c_doctype_id, name, 
-            templatelocation, reportfilename, templatefilename)
-      VALUES (GET_UUID(), ?, '0', 'Y', 
-            now(), '0', now(), '0', ?, ?, 
-            ?, ?, ?)
-      ]]>
-    </Sql>
-    <Parameter name="clientId"/>
-    <Parameter name="doctypeId"/>
-    <Parameter name="name"/>
-    <Parameter name="templatelocation"/>
-    <Parameter name="reportfilename"/>
-    <Parameter name="templatefilename"/>
-  </SqlMethod>
   <SqlMethod name="insertDoctypeTemplate2" type="preparedStatement" connection="true" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
--- a/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Thu Nov 26 16:35:30 2009 +0100
@@ -24,15 +24,18 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.fileupload.FileItem;
+import org.hibernate.criterion.Expression;
 import org.openbravo.base.filter.IsIDFilter;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
@@ -51,6 +54,9 @@
 import org.openbravo.erpCommon.utility.ToolBar;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.system.SystemInformation;
+import org.openbravo.model.ad.ui.Process;
+import org.openbravo.model.ad.ui.ProcessRequest;
+import org.openbravo.scheduling.ProcessBundle.Channel;
 import org.openbravo.services.webservice.Module;
 import org.openbravo.services.webservice.ModuleDependency;
 import org.openbravo.services.webservice.SimpleModule;
@@ -66,6 +72,7 @@
  */
 public class ModuleManagement extends HttpSecureAppServlet {
   private static final long serialVersionUID = 1L;
+  private static final String HB_Process_ID = "1005800000";
 
   /**
    * Main method that controls the sent command
@@ -776,7 +783,17 @@
 
   private boolean isHeartbeatEnabled() {
     SystemInformation sys = OBDal.getInstance().get(SystemInformation.class, "0");
-    return sys.isEnableHeartbeat() != null && sys.isEnableHeartbeat();
+    final Process HBProcess = OBDal.getInstance().get(Process.class, HB_Process_ID);
+    final boolean isHBEnabled = sys.isEnableHeartbeat() == null ? false : sys.isEnableHeartbeat();
+
+    final OBCriteria<ProcessRequest> prCriteria = OBDal.getInstance().createCriteria(
+        ProcessRequest.class);
+    prCriteria.add(Expression.eq(ProcessRequest.PROPERTY_PROCESS, HBProcess));
+    prCriteria.add(Expression.eq(ProcessRequest.PROPERTY_CHANNEL, Channel.SCHEDULED.toString()));
+    final List<ProcessRequest> prRequestList = prCriteria.list();
+
+    // Must exist a scheduled process request for HB and must be enable at SystemInfo level
+    return prRequestList.size() > 0 && isHBEnabled;
   }
 
   /**
--- a/src/org/openbravo/erpCommon/ad_forms/RemittanceCancel_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/RemittanceCancel_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -184,43 +184,6 @@
 	<Parameter name="line"/>
   </SqlMethod>
 
-    <SqlMethod name="returnDPGenerated" connection="true" type="preparedStatement" return="rowCount">
-    <SqlMethodComment>Principal select</SqlMethodComment>
-    <Sql>
-    <![CDATA[
-         insert into C_DP_ManagementLine
-           (C_DP_MANAGEMENTLINE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, 
-            C_DP_MANAGEMENT_ID, STATUS_FROM, STATUS_TO, C_DEBT_PAYMENT_ID, LINE)
-         values
-           (TO_NUMBER(?),TO_NUMBER(?), TO_NUMBER(?), 'Y', now(), TO_NUMBER(?), now(), TO_NUMBER(?), 
-            TO_NUMBER(?), (select dp.status
-                        from c_debt_payment dp,
-                             c_remittanceLine rl
-                       where c_RemittanceLine_ID = ?
-                         and dp.c_debt_payment_id = rl.C_DEBT_PAYMENT_CANCELLED), 
-                     (select STATUS_RETURNED
-                        from c_remittanceLine rl,
-                             c_remittance r,
-                             c_remittance_type rt
-                       where rl.c_remittance_id = r.c_remittance_id
-                         and r.c_remittance_type_id  = rt.c_remittance_type_id
-                         and rl.c_RemittanceLine_ID = ?),
-                     (select C_DEBT_PAYMENT_CANCELLED
-                        from c_remittanceLine rl
-                       where c_RemittanceLine_ID = ?), ?)
-      ]]></Sql>
-    <Parameter name="LID"/>
-    <Parameter name="client"/>
-    <Parameter name="org"/>
-    <Parameter name="user"/>
-    <Parameter name="user"/>
-    <Parameter name="DPMId"/>
-    <Parameter name="cRemittanceLine"/>
-    <Parameter name="cRemittanceLine"/>
-    <Parameter name="cRemittanceLine"/>
-    <Parameter name="line"/>
-  </SqlMethod>
-
   <SqlMethod name="selectLineNo" type="preparedStatement" return="rowCount">
     <Sql>
       <![CDATA[
--- a/src/org/openbravo/erpCommon/ad_forms/SQLExecutor.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/SQLExecutor.java	Thu Nov 26 16:35:30 2009 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -246,18 +246,15 @@
         dataHeader[i] = new SQLExecutorData();
         dataHeader[i].header = data[0].name.elementAt(i);
       }
-      dataBuffer.append("<tr>\n");
       for (int j = 0; j < data.length; j++) {
-        if (j != 0) {
-          int evenOdd = j % 2;
-          dataBuffer.append("<tr class=\"TableDetailRow" + String.valueOf(evenOdd) + "\">\n");
-          for (int k = 0; k < data[0].name.size(); k++) {
-            dataBuffer.append("<td>");
-            dataBuffer.append(data[j].getField(Integer.toString(k)));
-            dataBuffer.append("</td>\n");
-          }
-          dataBuffer.append("</tr>\n");
+        int evenOdd = j % 2;
+        dataBuffer.append("<tr class=\"TableDetailRow" + String.valueOf(evenOdd) + "\">\n");
+        for (int k = 0; k < data[0].name.size(); k++) {
+          dataBuffer.append("<td>");
+          dataBuffer.append(data[j].getField(Integer.toString(k)));
+          dataBuffer.append("</td>\n");
         }
+        dataBuffer.append("</tr>\n");
       }
     }
     /*
--- a/src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2008 Openbravo S.L.
+ * All portions are Copyright (C) 2001-2009 Openbravo S.L.
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -112,21 +112,4 @@
       <Parameter name="tadTransactionalrange"/>
       <Parameter name="tadTheme"/>
   </SqlMethod>
-  <SqlMethod name="insert" type="preparedStatement" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql><![CDATA[
-      INSERT INTO AD_PREFERENCE (AD_PREFERENCE_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, 
-      CREATED, CREATEDBY, UPDATED, UPDATEDBY, AD_USER_ID, ATTRIBUTE, VALUE)
-      VALUES (TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),'Y', 
-      now(), TO_NUMBER(?), now(), TO_NUMBER(?), TO_NUMBER(?), ?, ?)
-    ]]></Sql>
-      <Parameter name="adPreferenceId"/>
-      <Parameter name="adClientId"/>
-      <Parameter name="adOrgId"/>
-      <Parameter name="adUserId"/>
-      <Parameter name="adUserId"/>
-      <Parameter name="adUserId"/>
-      <Parameter name="attribute"/>
-      <Parameter name="value"/>
-  </SqlMethod>
 </SqlClass>
--- a/src/org/openbravo/erpCommon/ad_help/DisplayHelp_Edit_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_help/DisplayHelp_Edit_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -416,7 +416,7 @@
       <SqlMethodComment></SqlMethodComment>
       <Sql>
       <![CDATA[
-        INSERT INTOAD_FORM_TRL( AD_PROCESS_TRL_ID, AD_PROCESS_ID, AD_LANGUAGE, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, NAME, DESCRIPTION, HELP, ISTRANSLATED) 
+        INSERT INTO AD_PROCESS_TRL( AD_PROCESS_TRL_ID, AD_PROCESS_ID, AD_LANGUAGE, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, NAME, DESCRIPTION, HELP, ISTRANSLATED) 
         VALUES (get_uuid(), ?, ?, 0, 0, 'Y', now(), ?, now(), ?, ?, NULL, ?, 'Y')
         ]]>
       </Sql>
--- a/src/org/openbravo/erpCommon/ad_process/AssetDelivery_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- *************************************************************************
- * 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) 2001-2006 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
--->
-
-
-
-
-
-<SqlClass name="AssetDeliveryData" package="org.openbravo.erpCommon.ad_process">
-  <SqlMethod name="select" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SELECT A_ASSET_ID, GUARANTEEDATE , '' AS ISHTML, '' AS MAILHEADER, '' AS MAILTEXT,
-         '' AS DOWNLOADURL, '' AS VERSIONNO, '' AS R_MAILTEXT_ID, '' AS EMAIL, '' AS EMAILUSER, '' AS EMAILUSERPW,
-         '' AS AD_USER_ID, '' AS LOT, '' AS SERNO, '' AS M_PRODUCT_ID
-        FROM A_ASSET A, M_PRODUCT P
-        WHERE A.M_PRODUCT_ID = P.M_PRODUCT_ID
-        AND 1=1
-      ]]>
-    </Sql>
-    <Parameter name="bpartner" optional="true" after="AND 1=1"><![CDATA[ AND A.C_BPARTNER_ID= ?]]></Parameter>
-    <Parameter name="product" optional="true" after="AND 1=1"><![CDATA[ AND P.M_PRODUCT_ID= ?]]></Parameter>
-    <Parameter name="assetgroup" optional="true" after="AND 1=1"><![CDATA[ AND A.A_ASSET_GROUP_ID= ?]]></Parameter>
-    <Parameter name="GuaranteeDate" optional="true" after="AND 1=1"><![CDATA[ AND TRUNC(GUARANTEEDATE) >= TRUNC(TO_DATE(?))]]></Parameter>
-  </SqlMethod>
-  <SqlMethod name="getUser" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT AD_USER_ID 
-      FROM A_ASSET
-      WHERE A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="isActive" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT ISACTIVE 
-      FROM A_ASSET
-      WHERE A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="guaranteeDate" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT to_char(GUARANTEEDATE , to_char(?)) AS GUARANTEEDATE
-      FROM A_ASSET
-      WHERE A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="dateFormat"/>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="isSMTPAuthorization" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT ISSMTPAUTHORIZATION FROM AD_CLIENT
-      WHERE AD_CLIENT_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="AdClientId"/>
-  </SqlMethod>
-  <SqlMethod name="selectSMTPHost" type="preparedStatement" return="String" default="">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SELECT SMTPHost AS NAME FROM AD_Client WHERE AD_Client_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="adClientId"/>
-  </SqlMethod>
-  <SqlMethod name="selectAssetHelp" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT HELP 
-      FROM A_ASSET
-      WHERE A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="getEmail" type="preparedStatement" return="String">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT EMAIL FROM AD_USER
-      WHERE AD_USER_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="adUserId"/>
-  </SqlMethod>
-  <SqlMethod name="selectMailtext" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT ISHTML, MAILHEADER, MAILTEXT 
-      FROM R_MAILTEXT
-      WHERE R_MAILTEXT_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="rMailtextId"/>
-  </SqlMethod>
-  <SqlMethod name="selectEmailRequest" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SELECT RequestEMail AS EMail, RequestUser AS EMailUser, RequestUserPw AS EMailUserPw 
-        FROM AD_Client WHERE AD_Client_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="adClientId"/>
-  </SqlMethod>
-  <SqlMethod name="selectProductInfo" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT P.DOWNLOADURL, P.VERSIONNO, P.M_PRODUCT_ID
-      FROM M_PRODUCT P, A_ASSET A
-      WHERE P.M_PRODUCT_ID = A.M_PRODUCT_ID
-      AND A.A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="selectAssetInfo" type="preparedStatement" return="multiple">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      SELECT AD_USER_ID, LOT, SERNO, VERSIONNO
-      FROM A_ASSET A
-      WHERE A.A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="update" type="preparedStatement" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      UPDATE A_ASSET SET HELP = HELP || ?, ISACTIVE = 'N'
-      WHERE A_ASSET_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="help"/>
-    <Parameter name="aAssetId"/>
-  </SqlMethod>
-  <SqlMethod name="insert" type="preparedStatement" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      INSERT INTO A_ASSET_DELIVERY (AD_CLIENT_ID, AD_ORG_ID,ISACTIVE,CREATED, CREATEDBY,UPDATED, UPDATEDBY,
-      A_ASSET_DELIVERY_ID,A_ASSET_ID, MOVEMENTDATE, VERSIONNO, LOT, SERNO, EMAIL, AD_USER_ID)
-      VALUES(?, ?, 'Y',now(), ?, now(), ?, ?, ?, TO_DATE(?), ?, ?, ?, ?, ?)
-      ]]>
-    </Sql>
-    <Parameter name="adClientId"/>
-    <Parameter name="adOrgId"/>
-    <Parameter name="adUserId"/>
-    <Parameter name="adUserId"/>
-    <Parameter name="aAssetdeliveryId"/>
-    <Parameter name="aAssetId"/>
-    <Parameter name="movementdate"/>
-    <Parameter name="versionno"/>
-    <Parameter name="lot"/>
-    <Parameter name="serno"/>
-    <Parameter name="email"/>
-    <Parameter name="user"/>
-  </SqlMethod>
-</SqlClass>
--- a/src/org/openbravo/erpCommon/ad_process/BPartner_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/BPartner_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -56,591 +56,4 @@
 		<Parameter name="adClientId"/>
 		</SqlMethod>
 
-	<SqlMethod name="deleteOld" type="preparedStatement" connection="true" return="rowCount">
-	  <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-      DELETE FROM I_BPartner WHERE I_IsImported='Y'
-      AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateRecords" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-        SET AD_Client_ID = COALESCE(AD_Client_ID, ?),
-        AD_Org_ID = COALESCE(AD_Org_ID, 0),
-        IsActive = COALESCE(IsActive, 'Y'),
-        Created = COALESCE(Created, now()),
-        CreatedBy = COALESCE(CreatedBy, 0),
-        Updated = COALESCE(Updated, now()),
-        UpdatedBy = COALESCE(UpdatedBy, 0),
-        I_ErrorMsg = NULL,
-        I_IsImported = 'N' 
-        WHERE I_IsImported<>'Y' OR I_IsImported IS NULL
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateBPGroupDefault" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET GroupValue=(
-            SELECT MIN(Value) FROM C_BP_Group g
-            WHERE g.IsDefault='Y'
-              AND g.AD_Client_ID=I_BPartner.AD_Client_ID
-            ) 
-			  WHERE GroupValue IS NULL
-          AND C_BP_Group_ID IS NULL
-			    AND I_IsImported<>'Y'
-          AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateBPGroupId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner
-			  SET C_BP_Group_ID=(
-          SELECT C_BP_Group_ID FROM C_BP_Group g
-			    WHERE I_BPartner.GroupValue=g.Value AND g.AD_Client_ID=I_BPartner.AD_Client_ID
-        )
-			  WHERE C_BP_Group_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateGroupError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner
-			  SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Group, ' 
-			  WHERE C_BP_Group_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateCountryCodeDefault" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET CountryCode=(
-          SELECT MIN(CountryCode) FROM C_Country c
-          WHERE c.IsDefault='Y'
-            AND c.AD_Client_ID IN (0, I_BPartner.AD_Client_ID)
-        )
-			  WHERE CountryCode IS NULL
-        AND C_Country_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateCountryId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET C_Country_ID=(
-          SELECT C_Country_ID FROM C_Country c
-  			  WHERE I_BPartner.CountryCode=c.CountryCode
-          AND c.AD_Client_ID IN (0, I_BPartner.AD_Client_ID)
-        )
-			  WHERE C_Country_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateCountryError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner
-			  SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Country, '
-			  WHERE C_Country_ID IS NULL
-  			  AND I_IsImported<>'Y'
-          AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateRegionDefault" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET RegionName=(
-          SELECT MIN(Name) FROM C_Region r
-			    WHERE r.IsDefault='Y'
-          AND r.C_Country_ID=I_BPartner.C_Country_ID
-			    AND r.AD_Client_ID IN (0, I_BPartner.AD_Client_ID)
-        )
-			  WHERE RegionName IS NULL
-        AND C_Region_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateRegionId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET C_Region_ID=(
-          SELECT C_Region_ID FROM C_Region r
-			    WHERE r.Name=I_BPartner.RegionName
-          AND r.C_Country_ID=I_BPartner.C_Country_ID
-			    AND r.AD_Client_ID IN (0, I_BPartner.AD_Client_ID)
-        )
-			  WHERE C_Region_ID IS NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateRegionError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Region, '
-			  WHERE C_Region_ID IS NULL
-			  AND EXISTS (
-          SELECT * FROM C_Country c
-			    WHERE c.C_Country_ID=I_BPartner.C_Country_ID
-          AND c.HasRegion='Y'
-        )
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateGreetingId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET C_Greeting_ID=(
-          SELECT C_Greeting_ID FROM C_Greeting g
-			    WHERE I_BPartner.BPContactGreeting=g.Name
-          AND g.AD_Client_ID IN (0, I_BPartner.AD_Client_ID)
-        )
-			  WHERE C_Greeting_ID IS NULL
-        AND BPContactGreeting IS NOT NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateGreetingError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Greeting, '
-			  WHERE C_Greeting_ID IS NULL
-        AND BPContactGreeting IS NOT NULL
-			  AND I_IsImported<>'Y'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateBPartnerId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET C_BPartner_ID=(
-          SELECT C_BPartner_ID FROM C_BPartner p
-			    WHERE I_BPartner.Value=p.Value
-          AND p.AD_Client_ID=I_BPartner.AD_Client_ID
-        )
-			  WHERE C_BPartner_ID IS NULL
-        AND Value IS NOT NULL
-			  AND I_IsImported='N'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateADUserId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET AD_User_ID=(
-          SELECT AD_User_ID FROM AD_User c
-			    WHERE I_BPartner.ContactName=c.Name
-          AND I_BPartner.C_BPartner_ID=c.C_BPartner_ID
-          AND c.AD_Client_ID=I_BPartner.AD_Client_ID
-        )
-			  WHERE C_BPartner_ID IS NOT NULL
-        AND AD_User_ID IS NULL
-        AND ContactName IS NOT NULL
-			  AND I_IsImported='N'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="updateLocationId" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        UPDATE I_BPartner 
-			  SET C_BPartner_Location_ID=(
-          SELECT C_BPartner_Location_ID
-			    FROM C_BPartner_Location bpl INNER JOIN C_Location l ON (bpl.C_Location_ID=l.C_Location_ID)
-			    WHERE I_BPartner.C_BPartner_ID=bpl.C_BPartner_ID
-          AND bpl.AD_Client_ID=I_BPartner.AD_Client_ID
-			    AND DUMP(I_BPartner.Address1)=DUMP(l.Address1)
-          AND DUMP(I_BPartner.Address2)=DUMP(l.Address2)
-			    AND DUMP(I_BPartner.City)=DUMP(l.City)
-          AND DUMP(I_BPartner.Postal)=DUMP(l.Postal)
-          AND DUMP(I_BPartner.Postal_Add)=DUMP(l.Postal_Add)
-			    AND DUMP(I_BPartner.C_Region_ID)=DUMP(l.C_Region_ID)
-          AND DUMP(I_BPartner.C_Country_ID)=DUMP(l.C_Country_ID)
-        )
-			  WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL
-			  AND I_IsImported='N'
-        AND AD_Client_ID = ?
-      ]]>
-    </Sql>
-    <Parameter name="ad_client_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPartner" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-			  INSERT INTO C_BPartner (C_BPartner_ID, AD_Client_ID, AD_Org_ID,
-          IsActive,Created,CreatedBy,Updated,UpdatedBy,Value,Name,Name2,
-          Description,DUNS,TaxID,NAICS,C_BP_Group_ID,IsSummary)
-  				  SELECT ?, AD_Client_ID, AD_Org_ID,
-            'Y',now(),CreatedBy,now(),UpdatedBy,Value,Name,Name2,
-            Description,DUNS,TaxID,NAICS,C_BP_Group_ID,'N'
-			  	  FROM I_BPartner
-				    WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="CBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPartnerError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Insert BPartner, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="updateBPartner" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				UPDATE C_BPartner
-				SET 
-          Value=(
-          SELECT Value
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),Name=(
-          SELECT Name
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),Name2=(
-          SELECT ,Name2
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),Description=(
-          SELECT Description
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),DUNS=(
-          SELECT DUNS
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),TaxID=(
-          SELECT TaxID
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),NAICS=(
-          SELECT NAICS
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),C_BP_Group_ID=(
-          SELECT C_BP_Group_ID
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        ),Updated=now()
-        ,UpdatedBy=(
-          SELECT UpdatedBy
-          FROM I_BPartner
-				  WHERE I_BPartner_ID=?
-        )
-				WHERE C_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="CBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="updateBPartnerError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Update BPartner, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertLocation" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				INSERT INTO C_Location (
-          C_Location_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-          Address1,Address2,City,Postal,Postal_Add,C_Country_ID,C_Region_ID
-        )
-				SELECT ?,AD_Client_ID,AD_Org_ID,'Y',now(),CreatedBy,now(),UpdatedBy,
-				Address1,Address2,City,Postal,Postal_Add,C_Country_ID,C_Region_ID
-				FROM I_BPartner
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="CLocationID"/>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertLocationError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Insert Location, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPLocation" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				INSERT INTO C_BPartner_Location (
-          C_BPartner_Location_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-				  Name,IsBillTo,IsShipTo,IsPayFrom,IsRemitTo,Phone,Phone2,Fax, C_BPartner_ID,C_Location_ID
-        )
-				SELECT ?,AD_Client_ID,AD_Org_ID,'Y',now(),CreatedBy,now(),UpdatedBy,
-				City,'Y','Y','Y','Y',Phone,Phone2,Fax, ?,?
-				FROM I_BPartner
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="CBPLocationID"/>
-    <Parameter name="CBPartnerID"/>
-    <Parameter name="CLocationID"/>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPLocationError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Insert BPartnerLocation, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPContact" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				INSERT INTO AD_User (
-          AD_User_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,
-				  C_BPartner_ID,C_BPartner_Location_ID,C_Greeting_ID,Name,Title,Description,Comments,Phone,Phone2,Fax,EMail,Birthday
-        )
-				SELECT ?,AD_Client_ID,AD_Org_ID,'Y',now(),CreatedBy,now(),UpdatedBy,
-				?,?,C_Greeting_ID,ContactName,Title,ContactDescription,Comments,Phone,Phone2,Fax,EMail,Birthday
-				FROM I_BPartner
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="ADUserID"/>
-    <Parameter name="CBPartnerID"/>
-    <Parameter name="CBPLocationID"/>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="insertBPContactError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Insert BPContact, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="updateBPContact" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				UPDATE AD_User
-				SET 
-          C_Greeting_ID=(
-          SELECT C_Greeting_ID
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Name=(
-          SELECT ContactName
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Title=(
-          SELECT Title
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Description=(
-          SELECT ContactDescription
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Comments=(
-          SELECT Comments
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Phone=(
-          SELECT Phone
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Phone2=(
-          SELECT Phone2
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Fax=(
-          SELECT Fax
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),EMail=(
-          SELECT EMail
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Birthday=(
-          SELECT Birthday
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        ),Updated=now(),
-        UpdatedBy=(
-          SELECT UpdatedBy
-				  FROM I_BPartner
-          WHERE I_BPartner_ID=?
-        )
-				WHERE AD_User_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="IBPartnerID"/>
-    <Parameter name="ADUserID"/>
-  </SqlMethod>
-
-  <SqlMethod name="updateBPContactError" type="preparedStatement" connection="true" return="rowCount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-        SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Update BPContact, '
-				WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="i_bpartner_id"/>
-  </SqlMethod>
-
-  <SqlMethod name="setImported" type="preparedStatement" connection="true" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				UPDATE I_BPartner
-        SET I_IsImported='Y', C_BPartner_id = ?, C_BPartner_Location_id = ?, AD_User_id = ?, Updated=now(), Processed='Y'
-        WHERE I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="CBPartnerID"/>
-    <Parameter name="CBPLocationID"/>
-    <Parameter name="ADUserID"/>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
-  <SqlMethod name="updateNotImported" type="preparedStatement" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-      <![CDATA[
-				UPDATE I_BPartner
-        SET I_IsImported='N', Updated=now()
-			  WHERE I_IsImported<>'Y'
-        AND I_BPartner_ID=?
-      ]]>
-    </Sql>
-    <Parameter name="IBPartnerID"/>
-  </SqlMethod>
-
 </SqlClass>
--- a/src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice.html	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice.html	Thu Nov 26 16:35:30 2009 +0100
@@ -54,35 +54,35 @@
 }
 function validate() {
 	var frm = document.frmMain;
-	if (frm.inpReportDateFrom.value!=null && frm.inpReportDateFrom.value!="" && !isValidDate(frm.inpReportDateFrom.value, frm.inpReportDateFrom.displayFormat)) {
-			setWindowElementFocus(frm.inpReportDateFrom);
+	if (document.getElementById('paramDateFrom').value!=null && document.getElementById('paramDateFrom').value!="" && !isValidDate(document.getElementById('paramDateFrom').value, document.getElementById('paramDateFrom').getAttribute('displayFormat'))) {
+			setWindowElementFocus(frm.paramDateFrom);
 			frm.inpReportDateFrom.select();
 			showJSMessage(5);
 			return false;
-	} else if (frm.inpReportDateTo.value!=null && frm.inpReportDateTo.value!="" && !isValidDate(frm.inpReportDateTo.value, frm.inpReportDateTo.displayFormat)) {
-			setWindowElementFocus(frm.inpReportDateTo);
+	} else if (document.getElementById('paramDateTo').value!=null && document.getElementById('paramDateTo').value!="" && !isValidDate(document.getElementById('paramDateTo').value, document.getElementById('paramDateTo').getAttribute('displayFormat'))) {
+			setWindowElementFocus(frm.paramDateTo);
 			frm.inpReportDateTo.select();
 			showJSMessage(5);
 			return false;
-	} else if (frm.inpDateinvoiced.value!=null && frm.inpDateinvoiced.value!="" && !isValidDate(frm.inpDateinvoiced.value, frm.inpDateinvoiced.displayFormat)) {
-			setWindowElementFocus(frm.inpDateinvoiced);
+	} else if (document.getElementById('paramDateinvoiced').value!=null && document.getElementById('paramDateinvoiced').value!="" && !isValidDate(document.getElementById('paramDateinvoiced').value, document.getElementById('paramDateinvoiced').getAttribute('displayFormat'))) {
+			setWindowElementFocus(frm.paramDateinvoiced);
 			frm.inpDateinvoiced.select();
 			showJSMessage(5);
 			return false;
 	}
-  if ((frm.inpReportDateFrom.value==null || frm.inpReportDateFrom.value=="")) {
+  if ((document.getElementById('paramDateFrom').value==null || document.getElementById('paramDateFrom').value=="")) {
     	setWindowElementFocus(frm.inpReportDateFrom);
 		frm.inpReportDateFrom.select();
 		showJSMessage(1);
 		return false;
 	}
-  if ((frm.inpReportDateTo.value==null || frm.inpReportDateTo.value=="")) {
+  if ((document.getElementById('paramDateTo').value==null || document.getElementById('paramDateTo').value=="")) {
     	setWindowElementFocus(frm.inpReportDateTo);
 		frm.inpReportDateTo.select();
 		showJSMessage(1);
 		return false;
 	}
-  if ((frm.inpDateinvoiced.value == null || frm.inpDateinvoiced.value == "")) {
+  if ((document.getElementById('paramDateinvoiced').value == null || document.getElementById('paramDateinvoiced').value == "")) {
     	setWindowElementFocus(frm.inpDateinvoiced);
 		frm.inpDateinvoiced.select();
 		showJSMessage(1);
--- a/src/org/openbravo/erpCommon/ad_reports/ReportProjectProfitabilityJR.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportProjectProfitabilityJR.java	Thu Nov 26 16:35:30 2009 +0100
@@ -125,7 +125,7 @@
     String discard[] = { "discard" };
     String strTreeOrg = "'" + strOrg + "'";
     if (strExpand.equals("Y"))
-      strTreeOrg = treeOrg(vars, strOrg);
+      strTreeOrg += treeOrg(vars, strOrg);
     ReportProjectProfitabilityData[] data = null;
 
     // Checks if there is a conversion rate for each of the transactions of
@@ -306,11 +306,11 @@
   private String treeOrg(VariablesSecureApp vars, String strOrg) throws ServletException {
     ReportProjectProfitabilityData[] dataOrg = ReportProjectProfitabilityData.selectOrg(this,
         strOrg, vars.getClient());
-    String strTreeOrg = "'" + strOrg + "'";
+    String strTreeOrg = "";
     for (int i = 0; i < dataOrg.length; i++) {
       strTreeOrg += "," + "'" + dataOrg[i].nodeId + "'";
       if (dataOrg[i].issummary.equals("Y"))
-        treeOrg(vars, dataOrg[i].nodeId);
+        strTreeOrg += treeOrg(vars, dataOrg[i].nodeId);
     }
     return strTreeOrg;
   }
--- a/src/org/openbravo/erpCommon/utility/Alert_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/utility/Alert_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -67,7 +67,7 @@
    		<![CDATA[
        INSERT INTO AD_Alert (AD_Alert_ID, AD_Client_ID, AD_Org_ID, IsActive, 
                       Created, CreatedBy, Updated, UpdatedBy, Description, AD_AlertRule_ID, Record_Id, Referencekey_ID)
-      		VALUES (AD_GET_NEXT_SEQUENCE('AD_Alert', 100000), 0, 0, 'Y', NOW(), 0, NOW(), 0, ?, ?, ?, ?)
+      		VALUES (get_uuid(), 0, 0, 'Y', NOW(), 0, NOW(), 0, ?, ?, ?, ?)
       ]]>
    	</Sql>
    	<Parameter name="description" />
--- a/src/org/openbravo/erpCommon/utility/reporting/printing/Poc_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpCommon/utility/reporting/printing/Poc_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2008 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -164,59 +164,6 @@
         </Sql>
         <Parameter name="adUserId"/> 
    </SqlMethod>   
-   
-   <SqlMethod name="insertEmail" type="preparedStatement" connection="true" return="rowCount">
-      <SqlMethodComment></SqlMethodComment>
-      <Sql> <![CDATA[
-        INSERT INTO
-        	C_POC_EMAIL
-        	(
-        		C_CRM_EMAIL_ID,
-        		AD_CLIENT_ID,
-        		AD_ORG_ID,
-        		ISACTIVE,
-        		CREATED,
-        		CREATEDBY,
-        		UPDATED,
-        		UPDATEDBY,
-        	
-        		SENDER_EMAIL,
-        		RECIPIENT_EMAIL,
-        		DATEOFEMAIL,
-        		SUBJECT,
-        		BODY,
-        		TYPE	
-        	)
-        	VALUES
-        	(
-        		?,
-        		?,
-        		?, 
-        		'Y', 
-        		now(), 
-        		?,
-				now(),
-				?,
-				
-				?,
-				?,
-				now(),
-				?,
-				?,
-				'out' 
-			)
-      ]]></Sql>
-        <Parameter name="bmPocEmailId"/>
-        <Parameter name="adClientId"/>
-        <Parameter name="adOrgId"/>
-        <Parameter name="adUserId"/>
-        <Parameter name="adUserId"/>
-        
-        <Parameter name="senderEmail"/>
-        <Parameter name="recipientEmail"/>
-        <Parameter name="subject"/>
-        <Parameter name="body"/>
-   </SqlMethod>
 
 </SqlClass>
 
--- a/src/org/openbravo/erpReports/TaxRegister_data.xsql	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/erpReports/TaxRegister_data.xsql	Thu Nov 26 16:35:30 2009 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -34,153 +34,7 @@
   </Sql>
   <Parameter name="taxregister_id"/>
   </SqlMethod>
- 
-  <SqlMethod name="selectChild" type="preparedStatement" return="multiple">
-  <SqlMethodComment>Active Tax Register </SqlMethodComment>
-  <Sql>
-  <![CDATA[
-        SELECT AD_Client_ID, AD_Org_ID, C_TaxRegister_ID,  C_TaxPayment_ID, LastRegAccumAmt , TaxTotalAmt , C_TaxRegister_Type_ID, Name ,PageNo  
-			FROM C_TAXREGISTER
-			WHERE ISACTIVE='Y'
-			And C_TaxPayment_ID = ?
-      ]]>
-  </Sql>
-  <Parameter name="taxpayment_id"/>
-  </SqlMethod>
-  
-  <SqlMethod name="insert" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Active Tax Register </SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  		INSERT INTO C_TAXREGISTER 
-  		(AD_Client_ID, AD_Org_ID, C_TaxRegister_ID, C_TaxPayment_ID, C_TaxRegister_Type_ID,PageNo,NAME,ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
-  		VALUES 
-  		(TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?), ? ,'Y', now(), TO_NUMBER(?), now(), TO_NUMBER(?))
- 		
-      ]]>
-  </Sql>
-  <Parameter name="client_id"/>
-  <Parameter name="org_id"/>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxpayment_id"/>
-  <Parameter name="taxregister_type_id"/>
-  <Parameter name="pageno" default='0'/>
-  <Parameter name="name" />
-  <Parameter name="createdby"/>
-  <Parameter name="updateby"/>
-  </SqlMethod>
-  
-  <SqlMethod name="insertLines" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Insert Tax Register Lines</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  		INSERT INTO C_TAXREGISTERLINE 
-  		(AD_Client_ID, AD_Org_ID, C_TaxRegisterLine_ID, C_TaxRegister_ID, C_InvoiceTax_ID, DocumentNO,C_Tax_ID,
-  		TAXBASEAMT,TAXAMT,TAXUNDAMT,EXEMPTAMT,NOVATAMT,TOTALAMT,INVOICEDATE, NAME,ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
-  		VALUES 
-  		(TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),
-  		TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_DATE( ? ) , ?,'Y', now(), TO_NUMBER(?), now(), TO_NUMBER(?))
- 		
-      ]]>
-  </Sql>
-  <Parameter name="client_id"/>
-  <Parameter name="org_id"/>
-  <Parameter name="taxregisterline_id"/>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="invoicetax_id"/>,
-  <Parameter name="documentno" default='0'/>
-  <Parameter name="tax_id"/>
-  
-  <Parameter name="taxbaseamt" default='0'/>
-  <Parameter name="taxamt" default='0'/>
-  <Parameter name="taxundamt" default='0'/>
-  <Parameter name="exemptamt" default='0'/>
-  <Parameter name="novatamt" default='0'/>
-  <Parameter name="totalamt" default='0'/>
-  <Parameter name="invoicedate" />
-  <Parameter name="name" />
-  <Parameter name="createdby"/>
-  <Parameter name="updateby"/>
 
-  </SqlMethod>
-  
-  <SqlMethod name="updateTaxTotalAmt" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Update Tax Register Totals</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  		UPDATE C_TAXREGISTER 
-  		SET TAXTOTALAMT =
-  		coalesce((SELECT SUM(TAXAMT) FROM C_TAXREGISTERLINE WHERE C_TAXREGISTER_id = ?),0)
-  	    WHERE C_TAXREGISTER_id = ? 		
-      ]]>
-  </Sql>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxregister_id"/>
-  </SqlMethod>
-
-<SqlMethod name="updateLastRegAccumAmt" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Update Tax Register Totals</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  	   UPDATE C_TAXREGISTER 
-  	   SET LASTREGACCUMAMT =
-  	   (SELECT TAXTOTALAMT FROM C_TAXREGISTER WHERE C_TAXREGISTER_ID=
-  	   (SELECT MAX(C_TAXREGISTER_ID) FROM C_TAXREGISTER, C_TAXPAYMENT
-  	   WHERE C_TAXREGISTER_ID <> ?
-  	   AND C_TAXREGISTER_TYPE_ID = ?
-  	   AND C_TAXREGISTER.C_TAXPAYMENT_ID=C_TAXPAYMENT.C_TAXPAYMENT_ID
-  	   AND C_TAXPAYMENT.DATETO = TO_DATE( ? )-1
-  	   AND C_TAXPAYMENT.PROCESSED='Y')) 
-  	   WHERE C_TAXREGISTER_id = ?		
-      ]]>
-  </Sql>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxregistertype_id"/>
-  <Parameter name="datefrom"/>
-  <Parameter name="taxregister_id"/>
-  
-  </SqlMethod>
-  
-  <SqlMethod name="updateRegAccumAmt" type="preparedStatement" return="rowcount">
-  <SqlMethodComment>Update Tax Register Totals</SqlMethodComment>
-  <Sql>
-  <![CDATA[
-  	   UPDATE C_TAXREGISTER 
-  	   SET LASTREGACCUMAMT =  
-  	   COALESCE( 
-  	   (SELECT TAXTOTALAMT FROM C_TAXREGISTER WHERE C_TAXREGISTER_ID=
-  	   (SELECT MAX(C_TAXREGISTER_ID) FROM C_TAXREGISTER, C_TAXPAYMENT
-  	   WHERE C_TAXREGISTER_ID <> ?
-  	   AND C_TAXREGISTER_TYPE_ID = ?
-  	   AND C_TAXREGISTER.C_TAXPAYMENT_ID=C_TAXPAYMENT.C_TAXPAYMENT_ID
-  	   AND C_TAXPAYMENT.DATETO = TO_DATE( ? )-1
-  	   AND C_TAXPAYMENT.PROCESSED='Y'
-  	   AND C_TAXPAYMENT.GENERATEPAYMENT='N'))
-  	   ,0)
-  	   +
-  	   COALESCE( 
-  	   (SELECT LASTREGACCUMAMT FROM C_TAXREGISTER WHERE C_TAXREGISTER_ID=
-  	   (SELECT MAX(C_TAXREGISTER_ID) FROM C_TAXREGISTER, C_TAXPAYMENT
-  	   WHERE C_TAXREGISTER_ID <> ?
-  	   AND C_TAXREGISTER_TYPE_ID = ?
-  	   AND C_TAXREGISTER.C_TAXPAYMENT_ID=C_TAXPAYMENT.C_TAXPAYMENT_ID
-  	   AND C_TAXPAYMENT.DATETO = TO_DATE( ? )-1
-  	   AND C_TAXPAYMENT.PROCESSED='Y'
-  	   AND C_TAXPAYMENT.GENERATEPAYMENT='N'))
-  	   ,0)
-  	   WHERE C_TAXREGISTER_id = ?		
-      ]]>
-  </Sql>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxregistertype_id"/>
-  <Parameter name="datefrom"/>
-  <Parameter name="taxregister_id"/>
-  <Parameter name="taxregistertype_id"/>
-  <Parameter name="datefrom"/>
-  <Parameter name="taxregister_id"/>
-  
-  </SqlMethod>
-  
   <SqlMethod name="selectPageNoPrior" type="preparedStatement" return="string">
   <SqlMethodComment>select PageNo Prior Period</SqlMethodComment>
   <Sql>
@@ -204,7 +58,7 @@
   <Sql>
   <![CDATA[
   		update c_taxregister
-  		set pageno= ? 
+  		set pageno = TO_NUMBER(?) 
   		where c_taxregister_id = ?  
       ]]>
   </Sql>
--- a/src/org/openbravo/service/dataset/DataSetService.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/dataset/DataSetService.java	Thu Nov 26 16:35:30 2009 +0100
@@ -60,14 +60,14 @@
 
   private static DataSetService instance;
 
-  public static DataSetService getInstance() {
+  public static synchronized DataSetService getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(DataSetService.class);
     }
     return instance;
   }
 
-  public static void setInstance(DataSetService instance) {
+  public static synchronized void setInstance(DataSetService instance) {
     DataSetService.instance = instance;
   }
 
--- a/src/org/openbravo/service/db/CallProcess.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/db/CallProcess.java	Thu Nov 26 16:35:30 2009 +0100
@@ -49,11 +49,11 @@
 
   private static CallProcess instance = new CallProcess();
 
-  public static CallProcess getInstance() {
+  public static synchronized CallProcess getInstance() {
     return instance;
   }
 
-  public static void setInstance(CallProcess instance) {
+  public static synchronized void setInstance(CallProcess instance) {
     CallProcess.instance = instance;
   }
 
--- a/src/org/openbravo/service/db/CallStoredProcedure.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/db/CallStoredProcedure.java	Thu Nov 26 16:35:30 2009 +0100
@@ -41,11 +41,11 @@
 
   private static CallStoredProcedure instance = new CallStoredProcedure();
 
-  public static CallStoredProcedure getInstance() {
+  public static synchronized CallStoredProcedure getInstance() {
     return instance;
   }
 
-  public static void setInstance(CallStoredProcedure instance) {
+  public static synchronized void setInstance(CallStoredProcedure instance) {
     CallStoredProcedure.instance = instance;
   }
 
--- a/src/org/openbravo/service/db/DataExportService.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/db/DataExportService.java	Thu Nov 26 16:35:30 2009 +0100
@@ -72,7 +72,7 @@
    * 
    * @return the DataExportService instance
    */
-  public static DataExportService getInstance() {
+  public static synchronized DataExportService getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(DataExportService.class);
     }
@@ -86,7 +86,7 @@
    * @param instance
    *          the DataExportService instance used by the
    */
-  public static void setInstance(DataExportService instance) {
+  public static synchronized void setInstance(DataExportService instance) {
     DataExportService.instance = instance;
   }
 
--- a/src/org/openbravo/service/db/DataImportService.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/db/DataImportService.java	Thu Nov 26 16:35:30 2009 +0100
@@ -71,14 +71,14 @@
 
   private static DataImportService instance;
 
-  public static DataImportService getInstance() {
+  public static synchronized DataImportService getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(DataImportService.class);
     }
     return instance;
   }
 
-  public static void setInstance(DataImportService instance) {
+  public static synchronized void setInstance(DataImportService instance) {
     DataImportService.instance = instance;
   }
 
--- a/src/org/openbravo/service/system/ModuleValidator.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/system/ModuleValidator.java	Thu Nov 26 16:35:30 2009 +0100
@@ -25,6 +25,7 @@
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
+import org.openbravo.base.model.NamingUtil;
 import org.openbravo.base.model.Property;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.base.structure.BaseOBObject;
@@ -32,6 +33,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.modules.VersionUtility;
 import org.openbravo.erpCommon.modules.VersionUtility.VersionComparator;
+import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.ad.module.Module;
 import org.openbravo.model.ad.module.ModuleDependency;
 import org.openbravo.model.ad.ui.Element;
@@ -100,6 +102,8 @@
 
     checkHasUIArtifact(module, result);
 
+    checkTableName(module, result);
+
     // disable this check until this issue has been commented:
     // https://issues.openbravo.com/view.php?id=7905
     // checkHasIllegalId(module, result);
@@ -303,6 +307,25 @@
 
   }
 
+  private void checkTableName(Module module, SystemValidationResult result) {
+    for (org.openbravo.model.ad.module.DataPackage pckg : module.getDataPackageList()) {
+      OBCriteria<Table> tablesCriteria = OBDal.getInstance().createCriteria(Table.class);
+      tablesCriteria.add(Expression.eq(Table.PROPERTY_DATAPACKAGE, pckg));
+      final List<Table> tables = tablesCriteria.list();
+      for (Table table : tables) {
+        final String name = table.getName();
+        if (NamingUtil.doesNameHaveIllegalChars(name)) {
+          result.addError(SystemValidationType.WRONG_NAME, "Table " + table.getName()
+              + " has a name containing illegal characters such as dot, comma, /, etc.");
+        } else if (NamingUtil.doesNameContainNonNormalCharacters(name)) {
+          result.addWarning(SystemValidationType.WRONG_NAME, "Table " + table.getName()
+              + " has a name containing less normal characters, "
+              + "it is best to only use characters from a to z, A to Z, 0 to 9 or _");
+        }
+      }
+    }
+  }
+
   private void checkJavaPackages(Module module, SystemValidationResult result) {
     for (org.openbravo.model.ad.module.DataPackage pckg : module.getDataPackageList()) {
       if (pckg.getJavaPackage() != null
--- a/src/org/openbravo/service/system/SystemService.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/system/SystemService.java	Thu Nov 26 16:35:30 2009 +0100
@@ -50,14 +50,14 @@
 public class SystemService implements OBSingleton {
   private static SystemService instance;
 
-  public static SystemService getInstance() {
+  public static synchronized SystemService getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(SystemService.class);
     }
     return instance;
   }
 
-  public static void setInstance(SystemService instance) {
+  public static synchronized void setInstance(SystemService instance) {
     SystemService.instance = instance;
   }
 
--- a/src/org/openbravo/service/web/BaseWebServiceServlet.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/web/BaseWebServiceServlet.java	Thu Nov 26 16:35:30 2009 +0100
@@ -70,6 +70,11 @@
     }
   }
 
+  protected void callServiceInSuper(HttpServletRequest request, HttpServletResponse response)
+      throws ServletException, IOException {
+    super.service(request, response);
+  }
+
   protected void doService(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
     try {
--- a/src/org/openbravo/service/web/UserContextCache.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/web/UserContextCache.java	Thu Nov 26 16:35:30 2009 +0100
@@ -48,14 +48,14 @@
 
   private static UserContextCache instance;
 
-  public static UserContextCache getInstance() {
+  public static synchronized UserContextCache getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(UserContextCache.class);
     }
     return instance;
   }
 
-  public static void setInstance(UserContextCache instance) {
+  public static synchronized void setInstance(UserContextCache instance) {
     UserContextCache.instance = instance;
   }
 
--- a/src/org/openbravo/service/web/WebServiceUtil.java	Thu Nov 26 16:11:17 2009 +0100
+++ b/src/org/openbravo/service/web/WebServiceUtil.java	Thu Nov 26 16:35:30 2009 +0100
@@ -50,14 +50,14 @@
 
   private static WebServiceUtil instance = new WebServiceUtil();
 
-  public static WebServiceUtil getInstance() {
+  public static synchronized WebServiceUtil getInstance() {
     if (instance == null) {
       instance = OBProvider.getInstance().get(WebServiceUtil.class);
     }
     return instance;
   }
 
-  public static void setInstance(WebServiceUtil instance) {
+  public static synchronized void setInstance(WebServiceUtil instance) {
     WebServiceUtil.instance = instance;
   }