[costadj]Merge from pi 02687eeace5e revision.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Wed, 03 Sep 2014 16:32:14 +0200
changeset 24857 77ea1cf6f335
parent 24856 2462329b5344 (current diff)
parent 24371 02687eeace5e (diff)
child 24858 898755b233d8
[costadj]Merge from pi 02687eeace5e revision.
lib/build/junit.jar
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/sourcedata/AD_AUXILIARINPUT.xml
src-db/database/sourcedata/AD_CALLOUT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_DATASET_TABLE.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_REF_TABLE.xml
src-db/database/sourcedata/AD_TAB.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/AD_TREENODE.xml
src-db/database/sourcedata/AD_VAL_RULE.xml
src-db/database/sourcedata/AD_WINDOW.xml
src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
src-db/database/sourcedata/OBUIAPP_PROCESS.xml
src-db/database/sourcedata/OBUISEL_SELECTOR.xml
src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml
src-test/org/openbravo/erpCommon/info/ClassicSelectorTest.java
src-test/org/openbravo/test/AllAntTaskTests.java
src-test/org/openbravo/test/AllQuickAntTaskTests.java
src-test/org/openbravo/test/AllTests.java
src-test/org/openbravo/test/AllWebserviceTests.java
src-test/org/openbravo/test/AntTaskTests.java
src-test/org/openbravo/test/accounting/RecordID2Test.java
src-test/org/openbravo/test/ant/AntTasksTest.java
src-test/org/openbravo/test/ant/BaseAntTest.java
src-test/org/openbravo/test/ant/CallWadTest.java
src-test/org/openbravo/test/ant/RestartTomcatTest.java
src-test/org/openbravo/test/authorisations.txt
src-test/org/openbravo/test/base/BaseTest.java
src-test/org/openbravo/test/base/HiddenObjectHelper.java
src-test/org/openbravo/test/dal/ADCachedMultiThreadTest.java
src-test/org/openbravo/test/dal/AdminContextTest.java
src-test/org/openbravo/test/dal/ComputedColumnsTest.java
src-test/org/openbravo/test/dal/DalComplexQueryRequisitionTest.java
src-test/org/openbravo/test/dal/DalComplexQueryTestOrderLine.java
src-test/org/openbravo/test/dal/DalConnectionProviderTest.java
src-test/org/openbravo/test/dal/DalCopyTest.java
src-test/org/openbravo/test/dal/DalFilterTest.java
src-test/org/openbravo/test/dal/DalPerformanceCriteriaTest.java
src-test/org/openbravo/test/dal/DalPerformanceExampleTest.java
src-test/org/openbravo/test/dal/DalPerformanceInventoryLineTest.java
src-test/org/openbravo/test/dal/DalPerformanceProductTest.java
src-test/org/openbravo/test/dal/DalPerformanceProxyTest.java
src-test/org/openbravo/test/dal/DalQueryTest.java
src-test/org/openbravo/test/dal/DalStoredProcedureTest.java
src-test/org/openbravo/test/dal/DalTest.java
src-test/org/openbravo/test/dal/DalUtilTest.java
src-test/org/openbravo/test/dal/DoOrgClientAccessCheckTest.java
src-test/org/openbravo/test/dal/DynamicEntityTest.java
src-test/org/openbravo/test/dal/HiddenUpdateTest.java
src-test/org/openbravo/test/dal/IssuesTest.java
src-test/org/openbravo/test/dal/MappingGenerationTest.java
src-test/org/openbravo/test/dal/OBContextTest.java
src-test/org/openbravo/test/dal/PerformanceGenerateInstanceTest.java
src-test/org/openbravo/test/dal/ReadByNameTest.java
src-test/org/openbravo/test/dal/SimpleDalReadTest.java
src-test/org/openbravo/test/dal/ValidationTest.java
src-test/org/openbravo/test/dal/ViewTest.java
src-test/org/openbravo/test/dal/test_13281.xml
src-test/org/openbravo/test/datasource/BaseDataSourceTestDal.java
src-test/org/openbravo/test/datasource/BaseDataSourceTestNoDal.java
src-test/org/openbravo/test/datasource/DatasourceTestUtil.java
src-test/org/openbravo/test/datasource/ProductSelectorDataSourceTest.java
src-test/org/openbravo/test/datasource/SelectorFieldPropertySelectorDSTest.java
src-test/org/openbravo/test/datasource/TestCSVEncoding.java
src-test/org/openbravo/test/datasource/TestComboDatasource.java
src-test/org/openbravo/test/doc/GenerateEntityModelWiki.java
src-test/org/openbravo/test/doc/entity_model_wiki.txt
src-test/org/openbravo/test/doc/entity_wiki.txt
src-test/org/openbravo/test/expression/EvaluationTest.java
src-test/org/openbravo/test/javascript/CompressionTest.java
src-test/org/openbravo/test/javascript/JavaScriptAPIChecker.java
src-test/org/openbravo/test/javascript/JavaScriptAPITest.java
src-test/org/openbravo/test/javascript/JavaScriptAntTest.java
src-test/org/openbravo/test/javascript/JavaScriptParser.java
src-test/org/openbravo/test/javascript/test-compression.js
src-test/org/openbravo/test/mimetypes/MimeTypeTest.java
src-test/org/openbravo/test/model/ClassLoaderTest.java
src-test/org/openbravo/test/model/FieldProviderTest.java
src-test/org/openbravo/test/model/IndexesTest.java
src-test/org/openbravo/test/model/OneToManyTest.java
src-test/org/openbravo/test/model/RuntimeModelTest.java
src-test/org/openbravo/test/model/TrlColumnsOraTypeTest.java
src-test/org/openbravo/test/model/UniqueConstraintTest.java
src-test/org/openbravo/test/model/UtilsTest.java
src-test/org/openbravo/test/modularity/DBPrefixTest.java
src-test/org/openbravo/test/modularity/DatasetServiceTest.java
src-test/org/openbravo/test/modularity/MergePropertiesTest.java
src-test/org/openbravo/test/modularity/TableNameTest.java
src-test/org/openbravo/test/preference/PreferenceTest.java
src-test/org/openbravo/test/security/AccessLevelTest.java
src-test/org/openbravo/test/security/AllDataAllowedOrganizationsTest.java
src-test/org/openbravo/test/security/AllowedOrganizationsTest.java
src-test/org/openbravo/test/security/EntityAccessTest.java
src-test/org/openbravo/test/security/WritableReadableOrganizationClientTest.java
src-test/org/openbravo/test/system/ErrorTextParserTest.java
src-test/org/openbravo/test/system/OBPropertiesProviderTest.java
src-test/org/openbravo/test/system/SystemServiceTest.java
src-test/org/openbravo/test/system/SystemValidatorTest.java
src-test/org/openbravo/test/webservice/BaseWSTest.java
src-test/org/openbravo/test/webservice/PerformanceTest.java
src-test/org/openbravo/test/webservice/WSAddRecordWithComputedColumns.java
src-test/org/openbravo/test/webservice/WSReadTest.java
src-test/org/openbravo/test/webservice/WSUpdateTest.java
src-test/org/openbravo/test/xml/ClientExportImportTest.java
src-test/org/openbravo/test/xml/DatasetExportTest.java
src-test/org/openbravo/test/xml/EntityXMLImportTestBusinessObject.java
src-test/org/openbravo/test/xml/EntityXMLImportTestReference.java
src-test/org/openbravo/test/xml/EntityXMLImportTestSingle.java
src-test/org/openbravo/test/xml/EntityXMLImportTestWarning.java
src-test/org/openbravo/test/xml/EntityXMLIssues.java
src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java
src-test/org/openbravo/test/xml/XMLBaseTest.java
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
src/org/openbravo/erpCommon/ad_forms/DocInventory.java
src/org/openbravo/materialmgmt/InventoryCountProcess.java
--- a/.classpath.template	Wed Sep 03 13:46:43 2014 +0200
+++ b/.classpath.template	Wed Sep 03 16:32:14 2014 +0200
@@ -21,14 +21,12 @@
 	<classpathentry kind="src" path="modules/org.openbravo.service.datasource/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.service.integration.openid/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.service.integration.google/src"/>
-	<classpathentry kind="src" path="src-test"/>
 	<classpathentry including="quartz.properties" kind="src" path="config"/>
 	<classpathentry kind="src" path="src-gen"/>
 	<classpathentry including="**/*.java" kind="src" path="srcAD"/>
 	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/srcAD"/>
 	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="lib/build/junit.jar"/>
 	<classpathentry kind="lib" path="lib/build/js.jar"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>
--- a/.hgsigs	Wed Sep 03 13:46:43 2014 +0200
+++ b/.hgsigs	Wed Sep 03 16:32:14 2014 +0200
@@ -151,3 +151,6 @@
 7de34ade782eae3f74b2df2471292e0da145eb47 0 iEYEABECAAYFAlN95g4ACgkQCX/oGf+2qkO62ACg74llt2Ngb7UyteX/drSuZ6/U8mIAn2I3sFYMtTZ3jzjR5zGOJ3M8/Ah0
 e6d5de2bb5e230b5a9d6d95489292a8e92de1764 0 iEYEABECAAYFAlOhX0gACgkQCX/oGf+2qkOgGACg3wrp9HA+P7exN/j+Znu5acph2psAn1XulrvCL3RJ0r2iNyeVqaY73OtQ
 79d26cfa1fe16e6ba26251919588218073d8682f 0 iEYEABECAAYFAlOrwz0ACgkQCX/oGf+2qkOPlQCfV15XdSozD91qAF751lOUOH3VwroAn08TYpciEyWBOxsFXend1IUEPsnA
+9607751357e9e3a411c0919759ed81196befcad9 0 iEYEABECAAYFAlPHZVkACgkQCX/oGf+2qkORBQCfZJPiBWcEMNURibADGn9o+u+snwgAoP4ZMSkLCsu4PSf75rZn4gStM4wh
+11ed6ecc0a194545a1f8a3af2b2674b0ec319f99 0 iEYEABECAAYFAlPblXoACgkQCX/oGf+2qkOuxACfX5e+wRgLJw88VUyHl32C+QC8PY8AoOoARsJUAOnu8IgYYwNjyw5xMlKC
+a9d6608b6cabe9e27fa31cbf2a49a69b2d583e0a 0 iEUEABECAAYFAlPfOfMACgkQCX/oGf+2qkP8GQCY8T/ZXMymIqGubZ6h2LbjE7Uc4gCg5A/numsq2gypnrNri+wMt1HLLWA=
--- a/.hgtags	Wed Sep 03 13:46:43 2014 +0200
+++ b/.hgtags	Wed Sep 03 16:32:14 2014 +0200
@@ -162,3 +162,6 @@
 6b79b2cff11381014860b41d7db9c3835c87069b 3.0PR14Q2.1
 10a75a864b9d99c5f92d913f6d29255a5b0241cb 3.0PR14Q2.2
 623357e87f6cc274e2b75b2eda60d11dd0c593d2 3.0PR14Q2.3
+73f3bc31a2293109ebdc6e5b2f8b3f1870df7528 3.0PR14Q2.4
+abfe5a20ef579b8edaf9866346ee876a00e87eee 3.0PR14Q2.5
+d7d2abe0f424775dcdf9139410ae161881be1fb8 3.0PR14Q3
--- a/build.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/build.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -12,7 +12,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2001-2013 Openbravo SLU
+* All portions are Copyright (C) 2001-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
@@ -250,12 +250,14 @@
     </fileset>
     <fileset dir="${base.lib}">
       <include name="**/*.jar" />
+      <exclude name="**/test/*.jar" />
     </fileset>
     <fileset dir="${base.db}/lib/">
       <include name="**/*.jar" />
     </fileset>
     <fileset dir="${base.modules}">
       <include name="*/lib/**" />
+       <exclude name="**/test/*.jar" />
     </fileset>
   </path>
 
@@ -575,20 +577,24 @@
     <ant dir="${base.src}" target="generate.entities.quick.forked" inheritAll="true" inheritRefs="true" />
   </target>
 
+  <target name="compile.test" depends="init">
+    <ant dir="${base.src.test}" target="compile.test" inheritAll="true" inheritRefs="true" />
+  </target>
+  
   <target name="run.tests" depends="init">
-    <ant dir="${base.src}" target="run.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.all.tests" depends="init">
-    <ant dir="${base.src}" target="run.all.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.all.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.webservice.tests" depends="init">
-      <ant dir="${base.src}" target="run.webservice.tests" inheritAll="true" inheritRefs="true" />
+      <ant dir="${base.src.test}" target="run.webservice.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.quick.tests" depends="init">
-    <ant dir="${base.src}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.api.test.javascript">
--- a/legal/Licensing.txt	Wed Sep 03 13:46:43 2014 +0200
+++ b/legal/Licensing.txt	Wed Sep 03 16:32:14 2014 +0200
@@ -157,7 +157,10 @@
 Under the ANTLR license (available at http://www.antlr.org/license.html)
 
 # junit.jar
-Under the CPL license (available at http://www.opensource.org/licenses/cpl1.0.php)
+Under the Eclipse Public License - v 1.0 (available at https://www.eclipse.org/legal/epl-v10.html)
+
+# hamcrest-all-1.3.jar
+Under the BSD 3-Clause license (avaliable at http://opensource.org/licenses/BSD-3-Clause)
 
 # js.jar
 # ob-rhino-1.6R7.jar
Binary file lib/build/junit.jar has changed
Binary file lib/test/hamcrest-all-1.3.jar has changed
Binary file lib/test/junit.jar has changed
Binary file modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/WrongPaymentsFromJournalLine.class has changed
Binary file modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/WrongPaymentsFromJournalLineData.class has changed
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -32,6 +32,7 @@
 V_OutstandingAmount NUMBER;
 V_DueAmount NUMBER;
 V_DayStillDue NUMBER;
+v_ConvertedAmount NUMBER;
 
 v_Client_ID VARCHAR2(32);
 v_Org_ID VARCHAR2(32);
@@ -43,6 +44,7 @@
 v_PaymentTerm C_INVOICE.C_PaymentTerm_ID%TYPE;
 v_PaymentRule C_INVOICE.PaymentRule%TYPE;
 v_Currency_ID VARCHAR2(32);
+v_bpCurrency_id VARCHAR2(32);
 v_BPartner_ID VARCHAR2(32);
 v_DateInvoiced DATE;
 v_TotalLines NUMBER;
@@ -136,6 +138,20 @@
     v_creditmultiplier := -1;
   END IF;
 
+  --Gets the business partner's currency
+  SELECT BP_Currency_ID
+  INTO v_bpCurrency_id
+  from C_BPartner
+  WHERE C_BPartner_ID = v_BPartner_ID;
+  
+  IF (v_bpCurrency_id is null) THEN
+    v_bpCurrency_id:= v_Currency_ID;
+
+    update c_bpartner
+    set BP_Currency_ID = v_bpCurrency_id
+    where c_bpartner_id =v_BPartner_ID;
+  END IF;
+
   -- complete invoice
   IF (p_docaction = 'CO') THEN
     -- Checking Payment Method ID is available
@@ -438,7 +454,7 @@
               --When difference amount is not 0 the payment schedule detail of the order has to be split. The difference
               --amount is the amount of the new psd that is not related to any invoice.
 
-              IF (v_differenceamount <> 0) THEN
+              IF (v_differenceamount * v_negativePS > 0) THEN
                 v_new_scheduledetailid := get_uuid();
                 INSERT INTO fin_payment_scheduledetail
                 (
@@ -510,7 +526,7 @@
 
 	      -- Create C_InvoiceTax_CashVAT records
 	      IF (v_IsCashVAT = 'Y' AND order_schdet.fin_payment_detail_id IS NOT NULL) THEN
-                v_PercentageCashVAT := abs(c_currency_round(v_scheduledetailamount * 100 / v_GrandTotal, v_Currency_ID, null));
+                v_PercentageCashVAT := c_currency_round(v_scheduledetailamount * 100 / v_GrandTotal, v_Currency_ID, null);
 		FOR cur_cinvoicetax IN (
 		  SELECT it.C_InvoiceTax_ID, it.taxamt, it.taxbaseamt
                   FROM C_InvoiceTax it INNER JOIN C_Tax t on (it.c_tax_id = t.c_tax_id)
@@ -595,8 +611,29 @@
       WHERE C_INVOICE_ID = P_RECORD_ID;
 
       -- Updating SO_CREDITUSED when Invoices are being processed
+      if(v_bpCurrency_id <> v_Currency_id) THEN
+        SELECT COUNT(*)
+        INTO v_Count
+        FROM C_Conversion_Rate_Document
+        WHERE C_Invoice_ID = P_RECORD_ID
+        AND C_Currency_ID = v_Currency_id
+        AND C_Currency_Id_To = v_bpCurrency_id;
+
+        IF v_Count >0 THEN
+          SELECT RATE*COALESCE(V_OutstandingAmount, 0) * v_creditmultiplier
+          INTO v_ConvertedAmount
+          FROM C_Conversion_Rate_Document
+          WHERE C_Invoice_ID = P_RECORD_ID
+          AND C_Currency_ID = v_Currency_id
+          AND C_Currency_Id_To = v_bpCurrency_id;        
+        ELSE
+          v_ConvertedAmount := C_Currency_Convert((COALESCE(V_OutstandingAmount, 0) * v_creditmultiplier), v_Currency_id, v_bpCurrency_id, v_DateInvoiced,'S', v_Client_ID, v_Org_ID);
+        END IF;
+      else
+        v_ConvertedAmount := COALESCE(V_OutstandingAmount, 0) * v_creditmultiplier;
+      end if;
       UPDATE C_BPARTNER
-      SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) + (COALESCE(V_OutstandingAmount, 0) * v_creditmultiplier)
+      SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) + v_ConvertedAmount
       WHERE C_BPARTNER_ID = v_BPartner_ID;
 
       -- Automatic creation of payment and financial transaction
@@ -773,7 +810,7 @@
                   
                 -- Create C_InvoiceTax_CashVAT records
 	      IF (v_IsCashVAT = 'Y') THEN
-                v_PercentageCashVAT := abs(c_currency_round(cur_linktopayment_scheddetails.AMOUNT * 100 / v_GrandTotal, v_Currency_ID, null));
+                v_PercentageCashVAT := c_currency_round(cur_linktopayment_scheddetails.AMOUNT * 100 / v_GrandTotal, v_Currency_ID, null);
                 FOR cur_cinvoicetax IN (
                   SELECT it.C_InvoiceTax_ID, it.taxamt, it.taxbaseamt
                   FROM C_InvoiceTax it INNER JOIN C_Tax t on (it.c_tax_id = t.c_tax_id)
@@ -923,8 +960,29 @@
                 WHERE C_INVOICE_ID = P_RECORD_ID
                   AND TOTALPAID = GRANDTOTAL;
                 -- Updating SO_CREDITUSED when PAYMENT OCCUR and is not set in RPAE status
+                if (v_bpCurrency_id <> v_Currency_id) then
+                  SELECT COUNT(*)
+                  INTO v_Count
+                  FROM C_Conversion_Rate_Document
+                  WHERE C_Invoice_ID = P_RECORD_ID
+                  AND C_Currency_ID = v_Currency_id
+                  AND C_Currency_Id_To = v_bpCurrency_id;
+
+                  IF v_Count >0 THEN
+                    SELECT RATE*(COALESCE(cur_paymentschedule.OUTSTANDINGAMT, 0) * v_creditmultiplier)
+                    INTO v_ConvertedAmount
+                    FROM C_Conversion_Rate_Document
+                    WHERE C_Invoice_ID = P_RECORD_ID
+                    AND C_Currency_ID = v_Currency_id
+                    AND C_Currency_Id_To = v_bpCurrency_id;
+                  ELSE
+                    v_ConvertedAmount := C_Currency_Convert((COALESCE(cur_paymentschedule.OUTSTANDINGAMT, 0) * v_creditmultiplier), v_Currency_id, v_bpCurrency_id, v_DateInvoiced,'S', v_Client_ID, v_Org_ID);
+                  END IF;  
+                else
+                  v_ConvertedAmount := (COALESCE(cur_paymentschedule.OUTSTANDINGAMT, 0) * v_creditmultiplier);
+                end if;
                 UPDATE C_BPARTNER
-                SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) - (COALESCE(cur_paymentschedule.OUTSTANDINGAMT, 0) * v_creditmultiplier)
+                SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) - v_ConvertedAmount
                 WHERE C_BPARTNER_ID = v_BPartner_ID;
               END IF;
             END LOOP;
@@ -1023,8 +1081,30 @@
       INTO v_PaidAmount, v_PaymentPlanExpectedTotal
       FROM FIN_PAYMENT_SCHEDULE
       WHERE FIN_PAYMENT_SCHEDULE.C_INVOICE_ID = p_record_id ;
+
+      if v_bpCurrency_id <> v_Currency_id then
+        SELECT COUNT(*)
+        INTO v_Count
+        FROM C_Conversion_Rate_Document
+        WHERE C_Invoice_ID = P_RECORD_ID
+        AND C_Currency_ID = v_Currency_id
+        AND C_Currency_Id_To = v_bpCurrency_id;
+
+        IF v_Count >0 THEN
+          SELECT RATE*((v_PaymentPlanExpectedTotal - v_PaidAmount) * v_creditmultiplier)
+          INTO v_ConvertedAmount
+          FROM C_Conversion_Rate_Document
+          WHERE C_Invoice_ID = P_RECORD_ID
+          AND C_Currency_ID = v_Currency_id
+          AND C_Currency_Id_To = v_bpCurrency_id;
+        ELSE
+          v_ConvertedAmount := C_Currency_Convert(((v_PaymentPlanExpectedTotal - v_PaidAmount) * v_creditmultiplier), v_Currency_id, v_bpCurrency_id, v_DateInvoiced,'S', v_Client_ID, v_Org_ID);
+        END IF;  
+      else
+        v_ConvertedAmount := ((v_PaymentPlanExpectedTotal - v_PaidAmount) * v_creditmultiplier);
+      END IF;
       UPDATE C_BPARTNER
-         SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) - ((v_PaymentPlanExpectedTotal - v_PaidAmount) * v_creditmultiplier)
+         SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) - v_convertedAmount
       WHERE C_BPARTNER_ID = v_BPartner_ID;
     END;
 
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_BNKSTM_LINE_CHECK_TRG.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/triggers/APRM_FIN_BNKSTM_LINE_CHECK_TRG.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -16,7 +16,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2010 Openbravo SLU
+* All portions are Copyright (C) 2010-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 *************************************************************************/
@@ -79,7 +79,9 @@
       OR(COALESCE(:OLD.DRAMOUNT, 0) <> COALESCE(:NEW.DRAMOUNT, 0))
       OR(COALESCE(:OLD.REFERENCENO, '0') <> COALESCE(:NEW.REFERENCENO, '0'))
       )) THEN
-      RAISE_APPLICATION_ERROR(-20000, '@APRM_BSTLine_Matched@');
+      IF (:NEW.FIN_FINACC_TRANSACTION_ID IS NOT NULL) THEN
+	RAISE_APPLICATION_ERROR(-20000, '@APRM_BSTLine_Matched@');
+      END IF;
     END IF;
 
   	END IF;
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -349,7 +349,7 @@
 <!--04CFE3A53162449380A253DE0B814AEF-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & (@showAddPayment@='Y' | @showAddPayment@ ='') & (@APRM_OrderIsPaid@='N' | @APRM_OrderIsPaid@ ='')]]></DISPLAYLOGIC>
 <!--04CFE3A53162449380A253DE0B814AEF-->  <DISPLAYLENGTH><![CDATA[0]]></DISPLAYLENGTH>
 <!--04CFE3A53162449380A253DE0B814AEF-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--04CFE3A53162449380A253DE0B814AEF-->  <SEQNO><![CDATA[540]]></SEQNO>
+<!--04CFE3A53162449380A253DE0B814AEF-->  <SEQNO><![CDATA[335]]></SEQNO>
 <!--04CFE3A53162449380A253DE0B814AEF-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--04CFE3A53162449380A253DE0B814AEF-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--04CFE3A53162449380A253DE0B814AEF-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -20496,7 +20496,7 @@
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & (@showAddPayment@='Y' | @showAddPayment@ ='') & (@APRM_OrderIsPaid@='N' | @APRM_OrderIsPaid@ ='')]]></DISPLAYLOGIC>
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <DISPLAYLENGTH><![CDATA[0]]></DISPLAYLENGTH>
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <SEQNO><![CDATA[530]]></SEQNO>
+<!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <SEQNO><![CDATA[415]]></SEQNO>
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--F4A594CF81DA4C0DB3A81BBFF0305C12-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -541,6 +541,18 @@
 <!--6E6B065C16C747A9AA784F7434276DBE-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--6E6B065C16C747A9AA784F7434276DBE--></AD_MESSAGE>
 
+<!--712C841E501642B881A998CCAC13E420--><AD_MESSAGE>
+<!--712C841E501642B881A998CCAC13E420-->  <AD_MESSAGE_ID><![CDATA[712C841E501642B881A998CCAC13E420]]></AD_MESSAGE_ID>
+<!--712C841E501642B881A998CCAC13E420-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--712C841E501642B881A998CCAC13E420-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--712C841E501642B881A998CCAC13E420-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--712C841E501642B881A998CCAC13E420-->  <VALUE><![CDATA[APRM_CreditWithNegativeAmt]]></VALUE>
+<!--712C841E501642B881A998CCAC13E420-->  <MSGTEXT><![CDATA[It is not necessary to use credit for this payment: Actual Payment is greater than Expected Payment.]]></MSGTEXT>
+<!--712C841E501642B881A998CCAC13E420-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--712C841E501642B881A998CCAC13E420-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--712C841E501642B881A998CCAC13E420-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--712C841E501642B881A998CCAC13E420--></AD_MESSAGE>
+
 <!--7918E1E75DF84F499AD21A51F53F9A9B--><AD_MESSAGE>
 <!--7918E1E75DF84F499AD21A51F53F9A9B-->  <AD_MESSAGE_ID><![CDATA[7918E1E75DF84F499AD21A51F53F9A9B]]></AD_MESSAGE_ID>
 <!--7918E1E75DF84F499AD21A51F53F9A9B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -949,6 +961,18 @@
 <!--B6F8970C7470421FA5375E61D71A8E73-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--B6F8970C7470421FA5375E61D71A8E73--></AD_MESSAGE>
 
+<!--B80A5CA4E2554B3EB706486A763B1297--><AD_MESSAGE>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <AD_MESSAGE_ID><![CDATA[B80A5CA4E2554B3EB706486A763B1297]]></AD_MESSAGE_ID>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <VALUE><![CDATA[APRM_NoDistributeMsg]]></VALUE>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <MSGTEXT><![CDATA[The amount has not been distributed because there are too many (>75) records]]></MSGTEXT>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--B80A5CA4E2554B3EB706486A763B1297-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--B80A5CA4E2554B3EB706486A763B1297--></AD_MESSAGE>
+
 <!--B9ECCDD15B1349B5B00DC6EE83AD869E--><AD_MESSAGE>
 <!--B9ECCDD15B1349B5B00DC6EE83AD869E-->  <AD_MESSAGE_ID><![CDATA[B9ECCDD15B1349B5B00DC6EE83AD869E]]></AD_MESSAGE_ID>
 <!--B9ECCDD15B1349B5B00DC6EE83AD869E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></NAME>
-<!--A918E3331C404B889D69AA9BFAFB23AC-->  <VERSION><![CDATA[3.0.23921]]></VERSION>
+<!--A918E3331C404B889D69AA9BFAFB23AC-->  <VERSION><![CDATA[3.0.24368]]></VERSION>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <DESCRIPTION><![CDATA[Managing your finances with an ERP does not have to be difficult. Enjoy a radically improved user experience that combines the power of an enterprise grade financial application with the simplicity and ease of a web 2.0 personal accounting service.]]></DESCRIPTION>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <HELP><![CDATA[Advanced Payables and Receivables Management simplifies and automates the business processes around the management of financial accounts, from the receipt and issue of payment, to the reconciliation of those events with bank statements.
 If you would like to help shape this module you are welcome to take part in the forum discussions or register feature requests or issues in the corresponding (Forum and Bug Tracking) sections in the Advanced Payables and Receivable project in the OB Forge.]]></HELP>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <AD_DEPENDENT_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_DEPENDENT_MODULE_ID>
-<!--89326AE95DAD449D85DFAB2C5B1C6683-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--89326AE95DAD449D85DFAB2C5B1C6683-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Selector]]></DEPENDANT_MODULE_NAME>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--B97FC854C6DD41E692161585645A900F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--B97FC854C6DD41E692161585645A900F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--B97FC854C6DD41E692161585645A900F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--B97FC854C6DD41E692161585645A900F-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--B97FC854C6DD41E692161585645A900F-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--B97FC854C6DD41E692161585645A900F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--B97FC854C6DD41E692161585645A900F-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--B97FC854C6DD41E692161585645A900F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -203,6 +203,7 @@
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <SEQNO><![CDATA[10]]></SEQNO>
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <AD_REFERENCE_VALUE_ID><![CDATA[EC75B6F5A9504DB6B3F3356EA85F15EE]]></AD_REFERENCE_VALUE_ID>
+<!--8A8E1C0D38F144D797698E48F464F97B-->  <AD_VAL_RULE_ID><![CDATA[CA425689672A42D7BE2158EE41E44F94]]></AD_VAL_RULE_ID>
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <COLUMNNAME><![CDATA[action]]></COLUMNNAME>
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--8A8E1C0D38F144D797698E48F464F97B-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
@@ -304,6 +305,7 @@
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <SEQNO><![CDATA[10]]></SEQNO>
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <AD_REFERENCE_VALUE_ID><![CDATA[EC75B6F5A9504DB6B3F3356EA85F15EE]]></AD_REFERENCE_VALUE_ID>
+<!--ADC43AD315004E2D8E2802E00C4F178B-->  <AD_VAL_RULE_ID><![CDATA[CA425689672A42D7BE2158EE41E44F94]]></AD_VAL_RULE_ID>
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <COLUMNNAME><![CDATA[action]]></COLUMNNAME>
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--ADC43AD315004E2D8E2802E00C4F178B-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -312,6 +312,18 @@
 <!--C5D1596D065545B49156C1F9426C9E14-->  <SEQNO><![CDATA[30]]></SEQNO>
 <!--C5D1596D065545B49156C1F9426C9E14--></AD_REF_LIST>
 
+<!--D82326E588CB4BF685FAE03B5097B108--><AD_REF_LIST>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <AD_REF_LIST_ID><![CDATA[D82326E588CB4BF685FAE03B5097B108]]></AD_REF_LIST_ID>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <VALUE><![CDATA[APRM_ShowNoDistributeMsg]]></VALUE>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <NAME><![CDATA[Show No Distribute Amount Message]]></NAME>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <DESCRIPTION><![CDATA[If not 'N', shows a message when the APRM distribution is not done due to having too many records]]></DESCRIPTION>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--D82326E588CB4BF685FAE03B5097B108-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--D82326E588CB4BF685FAE03B5097B108--></AD_REF_LIST>
+
 <!--DDCDE32A9FC046E694D5074144DD6AFF--><AD_REF_LIST>
 <!--DDCDE32A9FC046E694D5074144DD6AFF-->  <AD_REF_LIST_ID><![CDATA[DDCDE32A9FC046E694D5074144DD6AFF]]></AD_REF_LIST_ID>
 <!--DDCDE32A9FC046E694D5074144DD6AFF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -119,6 +119,17 @@
 <!--BE0A211D552A4DE8AC3E6658759B396F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--BE0A211D552A4DE8AC3E6658759B396F--></AD_VAL_RULE>
 
+<!--CA425689672A42D7BE2158EE41E44F94--><AD_VAL_RULE>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <AD_VAL_RULE_ID><![CDATA[CA425689672A42D7BE2158EE41E44F94]]></AD_VAL_RULE_ID>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <NAME><![CDATA[Process or Reactivate Imported Bank Statement]]></NAME>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <TYPE><![CDATA[S]]></TYPE>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <CODE><![CDATA[((@Processed@ = 'N' AND AD_Ref_List.value='P') OR (@Processed@ = 'Y' AND AD_Ref_List.value='R'))]]></CODE>
+<!--CA425689672A42D7BE2158EE41E44F94-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--CA425689672A42D7BE2158EE41E44F94--></AD_VAL_RULE>
+
 <!--D035365830AF466BA81F2AB8ECC6FAE0--><AD_VAL_RULE>
 <!--D035365830AF466BA81F2AB8ECC6FAE0-->  <AD_VAL_RULE_ID><![CDATA[D035365830AF466BA81F2AB8ECC6FAE0]]></AD_VAL_RULE_ID>
 <!--D035365830AF466BA81F2AB8ECC6FAE0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -15,6 +15,7 @@
 <!--4EEB3497082C4F2182E16A4371CD5D96-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
 <!--4EEB3497082C4F2182E16A4371CD5D96-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
 <!--4EEB3497082C4F2182E16A4371CD5D96-->  <ISGRIDLEGACY><![CDATA[Y]]></ISGRIDLEGACY>
+<!--4EEB3497082C4F2182E16A4371CD5D96-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--4EEB3497082C4F2182E16A4371CD5D96--></OBUIAPP_PROCESS>
 
 <!--6F87442DF7BC43AB8A666BDED2F7D64E--><OBUIAPP_PROCESS>
@@ -32,6 +33,7 @@
 <!--6F87442DF7BC43AB8A666BDED2F7D64E-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
 <!--6F87442DF7BC43AB8A666BDED2F7D64E-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
 <!--6F87442DF7BC43AB8A666BDED2F7D64E-->  <ISGRIDLEGACY><![CDATA[Y]]></ISGRIDLEGACY>
+<!--6F87442DF7BC43AB8A666BDED2F7D64E-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--6F87442DF7BC43AB8A666BDED2F7D64E--></OBUIAPP_PROCESS>
 
 <!--8D0D32CC819E449D9A08E0459B482963--><OBUIAPP_PROCESS>
@@ -48,7 +50,8 @@
 <!--8D0D32CC819E449D9A08E0459B482963-->  <UIPATTERN><![CDATA[OBUIAPP_PickAndExecute]]></UIPATTERN>
 <!--8D0D32CC819E449D9A08E0459B482963-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
 <!--8D0D32CC819E449D9A08E0459B482963-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
-<!--8D0D32CC819E449D9A08E0459B482963-->  <ISGRIDLEGACY><![CDATA[Y]]></ISGRIDLEGACY>
+<!--8D0D32CC819E449D9A08E0459B482963-->  <ISGRIDLEGACY><![CDATA[N]]></ISGRIDLEGACY>
+<!--8D0D32CC819E449D9A08E0459B482963-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--8D0D32CC819E449D9A08E0459B482963--></OBUIAPP_PROCESS>
 
 <!--9BED7889E1034FE68BD85D5D16857320--><OBUIAPP_PROCESS>
@@ -70,6 +73,7 @@
 <!--9BED7889E1034FE68BD85D5D16857320-->  <CLIENTSIDEVALIDATION><![CDATA[OB.APRM.AddPayment.onProcess]]></CLIENTSIDEVALIDATION>
 <!--9BED7889E1034FE68BD85D5D16857320-->  <ISGRIDLEGACY><![CDATA[N]]></ISGRIDLEGACY>
 <!--9BED7889E1034FE68BD85D5D16857320-->  <ON_LOAD_FUNCTION><![CDATA[OB.APRM.AddPayment.onLoad]]></ON_LOAD_FUNCTION>
+<!--9BED7889E1034FE68BD85D5D16857320-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--9BED7889E1034FE68BD85D5D16857320--></OBUIAPP_PROCESS>
 
 </data>
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/AllTests.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/AllTests.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,34 +19,47 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.openbravo.advpaymentmngt.test.draft.FinancialAccountTest;
+import org.openbravo.advpaymentmngt.test.draft.PaymentMethodTest;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_01;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_02;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_03;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_04;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_05;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_06;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_07;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_08;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_09;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_10;
+import org.openbravo.advpaymentmngt.test.draft.PaymentTest_11;
 
+/**
+ * 
+ * Test for org.openbravo.advpaymentmngt
+ * 
+ */
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+  
+    // Master Data Configuration
+    FinancialAccountTest.class, //
+    PaymentMethodTest.class,
+    
+    // Payment scenarios
+    PaymentTest_01.class, //
+    PaymentTest_02.class, //
+    PaymentTest_03.class, //
+    PaymentTest_04.class, //
+    PaymentTest_05.class, //
+    PaymentTest_06.class, //
+    PaymentTest_07.class, //
+    PaymentTest_08.class, //
+    PaymentTest_09.class, //
+    PaymentTest_10.class, //
+    PaymentTest_11.class })
 public class AllTests {
 
-  public static Test suite() {
-    final TestSuite suite = new TestSuite("Test for org.openbravo.advpaymentmngt");
-    // $JUnit-BEGIN$
-
-    // Master Data Configuration
-    suite.addTestSuite(FinancialAccountTest.class);
-    suite.addTestSuite(PaymentMethodTest.class);
-
-    // Payment scenarios
-    suite.addTestSuite(PaymentTest_01.class);
-    suite.addTestSuite(PaymentTest_02.class);
-    suite.addTestSuite(PaymentTest_03.class);
-    suite.addTestSuite(PaymentTest_04.class);
-    suite.addTestSuite(PaymentTest_05.class);
-    suite.addTestSuite(PaymentTest_06.class);
-    suite.addTestSuite(PaymentTest_07.class);
-    suite.addTestSuite(PaymentTest_08.class);
-    suite.addTestSuite(PaymentTest_09.class);
-    suite.addTestSuite(PaymentTest_10.class);
-    suite.addTestSuite(PaymentTest_11.class);
-
-    // $JUnit-END$
-    return suite;
-  }
-
 }
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/FinancialAccountTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/FinancialAccountTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -23,26 +23,32 @@
 import java.util.List;
 
 import org.hibernate.criterion.Restrictions;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.geography.Location;
 import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class FinancialAccountTest extends BaseTest {
+public class FinancialAccountTest extends OBBaseTest {
 
   private static final String BANK = "B";
   private static final String CASH = "C";
   private static final String STANDARD_DESCRIPTION = "JUnit Test";
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  /**
+   * This before method is named setUpF() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   */
+  @Before
+  public void setUpF() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testAddFinancialAccountValid1() {
     TestUtility.insertFinancialAccount("APRM_FINANCIAL_ACCOUNT_1", STANDARD_DESCRIPTION,
         getOneInstance(Currency.class), CASH, false, getOneInstance(Location.class),
@@ -51,6 +57,7 @@
   }
 
   // Pre-requisite: at least one Matching Algorithm created
+  @Test
   public void testAddFinancialAccountValid2() {
     TestUtility.insertFinancialAccount("APRM_FINANCIAL_ACCOUNT_2", STANDARD_DESCRIPTION,
         getOneInstance(Currency.class), BANK, false, getOneInstance(Location.class),
@@ -59,6 +66,7 @@
         null/* getOneInstance(MatchingAlgorithm.class) */, true, false);
   }
 
+  @Test
   public void testAddFinancialAccountValid3() {
     TestUtility.insertFinancialAccount("APRM_FINANCIAL_ACCOUNT_3", STANDARD_DESCRIPTION,
         getOneInstance(Currency.class), BANK, false, getOneInstance(Location.class),
@@ -69,6 +77,7 @@
   /**
    * Currency is mandatory
    */
+  @Test
   public void testAddFinancialAccountNotValid1() {
     TestUtility.insertFinancialAccount("APRM_FINANCIAL_ACCOUNT_4", STANDARD_DESCRIPTION, null,
         BANK, false, getOneInstance(Location.class), getOneInstance(BusinessPartner.class), "2054",
@@ -79,6 +88,7 @@
   /**
    * Deletes all the Payment Methods created for testing
    */
+  @Test
   public void testDeleteFinancialAccounts() {
     final OBCriteria<FIN_FinancialAccount> obCriteria = OBDal.getInstance().createCriteria(
         FIN_FinancialAccount.class);
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentMethodTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentMethodTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -22,12 +22,14 @@
 import java.util.List;
 
 import org.hibernate.criterion.Restrictions;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentMethodTest extends BaseTest {
+public class PaymentMethodTest extends OBBaseTest {
 
   private static final String AUTOMATIC_EXECUTION = "A";
   private static final String MANUAL_EXECUTION = "M";
@@ -37,12 +39,16 @@
   private static final String DEPOSIT_ACCOUNT = "DEP";
   private static final String STANDARD_DESCRIPTION = "JUnit Test";
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  /**
+   * This before method is named setUpP() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   */
+  @Before
+  public void setUpP() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testAddPaymentMethodValid1() {
     TestUtility.insertPaymentMethod("APRM_PAYMENT_METHOD_1", STANDARD_DESCRIPTION, true, false,
         false, MANUAL_EXECUTION, null, false, IN_TRANSIT_ACCOUNT, DEPOSIT_ACCOUNT, CLEARED_ACCOUNT,
@@ -50,6 +56,7 @@
         CLEARED_ACCOUNT, true, false);
   }
 
+  @Test
   public void testAddPaymentMethodValid2() {
     TestUtility.insertPaymentMethod("APRM_PAYMENT_METHOD_2", STANDARD_DESCRIPTION, true, false,
         false, AUTOMATIC_EXECUTION, null, false, IN_TRANSIT_ACCOUNT, DEPOSIT_ACCOUNT,
@@ -57,12 +64,14 @@
         WITHDRAWN_ACCOUNT, CLEARED_ACCOUNT, true, false);
   }
 
+  @Test
   public void testAddPaymentMethodValid3() {
     TestUtility.insertPaymentMethod("APRM_PAYMENT_METHOD_3", STANDARD_DESCRIPTION, true, false,
         false, MANUAL_EXECUTION, null, false, null, null, null, true, false, false,
         MANUAL_EXECUTION, null, false, null, null, null, true, false);
   }
 
+  @Test
   public void testAddPaymentMethodValid4() {
     TestUtility.insertPaymentMethod("APRM_PAYMENT_METHOD_4", STANDARD_DESCRIPTION, true, true,
         true, MANUAL_EXECUTION, null, false, null, null, null, true, true, true, MANUAL_EXECUTION,
@@ -70,6 +79,7 @@
   }
 
   // Requisite: at least one Execution Process created
+  @Test
   public void testAddPaymentMethodValid5() {
     TestUtility.insertPaymentMethod("APRM_PAYMENT_METHOD_5", STANDARD_DESCRIPTION, true, false,
         false, AUTOMATIC_EXECUTION, /* getOneInstance(PaymentExecutionProcess.class) */null, false,
@@ -82,6 +92,7 @@
   /**
    * Deletes all the Payment Methods created for testing
    */
+  @Test
   public void testDeletePaymentMethod() {
     final OBCriteria<FIN_PaymentMethod> obCriteria = OBDal.getInstance().createCriteria(
         FIN_PaymentMethod.class);
@@ -91,5 +102,4 @@
       OBDal.getInstance().remove(pm);
     }
   }
-
 }
\ No newline at end of file
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_01.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_01.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,15 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -42,9 +47,9 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_01 extends BaseTest {
+public class PaymentTest_01 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_01.class);
 
@@ -60,13 +65,17 @@
 
   /**
    * Initial Set up.
+   *  
+   * This before method is named setUpP01() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP01() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testRunPayment_01() {
     boolean exception = false;
     Invoice invoice = null;
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_02.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_02.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,14 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -42,14 +46,14 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * The PaymentTest_02 class used to test the partial payment document generation and reactivating
  * the in APRM.
  * 
  */
-public class PaymentTest_02 extends BaseTest {
+public class PaymentTest_02 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_01.class);
 
@@ -65,10 +69,13 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP02() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP02() throws Exception {
     TestUtility.setTestContext();
   }
 
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_03.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_03.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,15 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -42,13 +47,13 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * The PaymentTest_03 class used to test the payment document generation and reactivation with
  * write-off option.
  */
-public class PaymentTest_03 extends BaseTest {
+public class PaymentTest_03 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_01.class);
 
@@ -64,13 +69,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP03() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP03() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testRunPayment_03() {
     boolean exception = false;
     Invoice invoice = null;
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_04.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_04.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,15 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -41,12 +46,12 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * The PaymentTest_04 class used to test the payment document generation with Refund option.
  */
-public class PaymentTest_04 extends BaseTest {
+public class PaymentTest_04 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_04.class);
 
@@ -62,13 +67,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP04() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP04() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testRunPayment_04() {
     boolean exception = false;
     Invoice invoice = null;
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_05.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_05.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,6 +19,8 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
@@ -26,6 +28,8 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
 import org.openbravo.advpaymentmngt.process.FIN_AddPayment;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
@@ -46,13 +50,13 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * The PaymentTest_03 class used to test the payment document generation and reactivation with
  * write-off option.
  */
-public class PaymentTest_05 extends BaseTest {
+public class PaymentTest_05 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_05.class);
 
@@ -69,16 +73,20 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP05() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP05() throws Exception {
     TestUtility.setTestContext();
   }
 
   /**
    * Payment Proposal with two invoices of different business partner partially paid.
    */
+  @Test
   public void testRunPayment_05() {
     String fruitBio = "8A64B71A2B0B2946012B0FE1E45F01B0";
     String happyDrinks = "8A64B71A2B0B2946012B0FE1E37001AB";
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_06.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_06.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,15 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -43,12 +48,12 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * The PaymentTest_06 class used to test the payment document generation with execution process.
  */
-public class PaymentTest_06 extends BaseTest {
+public class PaymentTest_06 extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(PaymentTest_06.class);
 
@@ -64,13 +69,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP06() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP06() throws Exception {
     TestUtility.setTestContext();
   }
 
+  @Test
   public void testRunPayment_06() {
     boolean exception = false;
     Invoice invoice = null;
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_07.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_07.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,12 +19,17 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.process.FIN_ExecutePayment;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
@@ -50,9 +55,9 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_07 extends BaseTest {
+public class PaymentTest_07 extends OBBaseTest {
 
   // 1) Create an order with discount
   // 2) Add a partial payment but do not execute it
@@ -77,13 +82,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP07() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP07() throws Exception {
     TestUtility.setTestContextSpain();
   }
 
+  @Test
   public void testRunPayment_07() {
     boolean exception = false;
     try {
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_08.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_08.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,10 +19,15 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.dal.core.OBContext;
@@ -47,9 +52,9 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_08 extends BaseTest {
+public class PaymentTest_08 extends OBBaseTest {
 
   // 1) Create an order
   // 2) Add a partial payment but do not execute it
@@ -71,13 +76,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP08() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP08() throws Exception {
     TestUtility.setTestContextSpain();
   }
 
+  @Test
   public void testRunPayment_08() {
     boolean exception = false;
     try {
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_09.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_09.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,12 +19,17 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.process.FIN_ExecutePayment;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.base.provider.OBProvider;
@@ -53,9 +58,9 @@
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.discount.Discount;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_09 extends BaseTest {
+public class PaymentTest_09 extends OBBaseTest {
 
   // 1) Create an order without discount
   // 2) Add a partial payment but do not execute it
@@ -80,13 +85,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP09() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP09() throws Exception {
     TestUtility.setTestContextSpain();
   }
 
+  @Test
   public void testRunPayment_09() {
     boolean exception = false;
     try {
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_10.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_10.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,12 +19,17 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.process.FIN_ExecutePayment;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.base.provider.OBProvider;
@@ -53,9 +58,9 @@
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.discount.Discount;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_10 extends BaseTest {
+public class PaymentTest_10 extends OBBaseTest {
 
   // 1) Create an order without discount
   // 2) Add a partial payment but do not execute it
@@ -80,13 +85,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP10() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP10() throws Exception {
     TestUtility.setTestContextSpain();
   }
 
+  @Test
   public void testRunPayment_10() {
     boolean exception = false;
     try {
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_11.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/PaymentTest_11.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,11 +19,16 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -46,9 +51,9 @@
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class PaymentTest_11 extends BaseTest {
+public class PaymentTest_11 extends OBBaseTest {
 
   // 1) Create an order without discount
   // 2) Invoice the complete order (without discount)
@@ -70,13 +75,17 @@
 
   /**
    * Initial Set up.
+   * 
+   * This before method is named setUpP11() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   * 
    */
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpP11() throws Exception {
     TestUtility.setTestContextSpain();
   }
 
+  @Test
   public void testRunPayment_11() {
     boolean exception = false;
     FIN_Payment payment = null;
--- a/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/TestUtility.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-test/org/openbravo/advpaymentmngt/test/draft/TestUtility.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,6 +19,9 @@
 
 package org.openbravo.advpaymentmngt.test.draft;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
@@ -66,9 +69,9 @@
 import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.model.pricing.pricelist.PriceList;
 import org.openbravo.service.db.CallProcess;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class TestUtility extends BaseTest {
+public class TestUtility extends OBBaseTest {
 
   private static final Logger log = Logger.getLogger(TestUtility.class);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/WrongPaymentsFromJournalLine.java	Wed Sep 03 16:32:14 2014 +0200
@@ -0,0 +1,80 @@
+/* 
+ *************************************************************************
+ * 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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.advpaymentmngt.modulescript;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.modulescript.ModuleScript;
+
+public class WrongPaymentsFromJournalLine extends ModuleScript {
+  
+  final static private String ALERT_RULE_SQL = "select distinct ad_column_identifier('FIN_Payment', p.fin_payment_id, 'en_US') as record_id, p.fin_payment_id  as referencekey_id, 0 as ad_role_id, null as ad_user_id, 'This payment needs to be checked due to wrong amount.' as description, 'Y' as isActive, p.ad_org_id, p.ad_client_id, now() as created, 0 as createdBy, now() as updated, 0 as updatedBy from fin_payment p left join gl_journalline jl on jl.fin_payment_id = p.fin_payment_id where abs(jl.amtsourcedr-jl.amtsourcecr) != p.amount order by 1";
+  
+  @Override
+  // Inserting Alerts for payments created from G/L Journal Line with wrong amounts
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      WrongPaymentsFromJournalLineData[] data = WrongPaymentsFromJournalLineData.select(cp);
+      for (WrongPaymentsFromJournalLineData wrongPayment : data) {
+        createAlert(cp, wrongPayment);
+      }
+     } catch (Exception e) {
+      handleError(e);
+    }
+  }
+
+  private void createAlert(ConnectionProvider cp, WrongPaymentsFromJournalLineData wrongPayment)
+	      throws ServletException {
+	  	final String PAYMENT_IN_WINDOW = "E547CE89D4C04429B6340FFA44E70716";
+	    final String PAYMENT_OUT_WINDOW = "6F8F913FA60F4CBD93DC1D3AA696E76E";
+	    final String PAYMENT_IN_TAB = "C4B6506838E14A349D6717D6856F1B56";
+	    final String PAYMENT_OUT_TAB = "F7A52FDAAA0346EFA07D53C125B40404";
+	    String WindowOrderId = PAYMENT_OUT_WINDOW;
+	    String strTabId = PAYMENT_OUT_TAB;
+	    String ALERT_RULE = "Wrong Payment Out Amount";
+	    if ("Y".equals(wrongPayment.isreceipt)) {
+	      strTabId = PAYMENT_IN_TAB;
+	      WindowOrderId = PAYMENT_IN_WINDOW;	    
+	      ALERT_RULE = "Wrong Payment In Amount";
+	    }
+	    String strName = "Payment: '" + wrongPayment.paymentinfo
+	            + "' needs to be checked due to wrong amount.";
+	    String oldAlertRuleId = WrongPaymentsFromJournalLineData.getAlertRuleId(cp, ALERT_RULE,
+	            wrongPayment.adClientId);
+	    if (!WrongPaymentsFromJournalLineData.existsAlert(cp, oldAlertRuleId, wrongPayment.finPaymentId)) {
+	    if (!WrongPaymentsFromJournalLineData.existsAlertRule(cp, ALERT_RULE, wrongPayment.adClientId)) {
+	      WrongPaymentsFromJournalLineData.insertAlertRule(cp, wrongPayment.adClientId, ALERT_RULE, strTabId, "");
+	      WrongPaymentsFromJournalLineData[] roles = WrongPaymentsFromJournalLineData.getRoleId(cp,
+	            WindowOrderId, wrongPayment.adClientId);
+	        for (WrongPaymentsFromJournalLineData role : roles) {
+	          WrongPaymentsFromJournalLineData.insertAlertRecipient(cp, wrongPayment.adClientId,
+	              wrongPayment.adOrgId,
+	              WrongPaymentsFromJournalLineData.getAlertRuleId(cp, ALERT_RULE, wrongPayment.adClientId),
+	              role.adRoleId);
+	        }
+	      }
+	    	String alertRuleId = WrongPaymentsFromJournalLineData.getAlertRuleId(cp, ALERT_RULE,
+	            wrongPayment.adClientId);
+	    	WrongPaymentsFromJournalLineData.insertAlert(cp, wrongPayment.adClientId, wrongPayment.adOrgId,
+	          strName, alertRuleId, wrongPayment.paymentinfo, wrongPayment.finPaymentId);
+	    }
+  	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/WrongPaymentsFromJournalLine_data.xsql	Wed Sep 03 16:32:14 2014 +0200
@@ -0,0 +1,141 @@
+<?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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+-->
+<SqlClass name="WrongPaymentsFromJournalLineData" package="org.openbravo.advpaymentmngt.modulescript">
+   <SqlClassComment></SqlClassComment>
+   <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+      select distinct p.ad_client_id, ad_column_identifier('FIN_Payment', p.fin_payment_id, 'en_US') as paymentinfo, 
+      p.fin_payment_id, p.ad_org_id,  p.isreceipt, '' as ad_role_id, '' as ad_alertrule_id, '' as ad_alert_id 
+      from fin_payment p left join gl_journalline jl on jl.fin_payment_id = p.fin_payment_id 
+      where abs(jl.amtsourcedr-jl.amtsourcecr) != p.amount 
+      order by 1, 2
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="existsAlertRule" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT COUNT(*) AS EXISTING
+       FROM AD_ALERTRULE
+       WHERE NAME = ?
+         AND ISACTIVE = 'Y'
+         AND AD_CLIENT_ID = ?
+      ]]>
+    </Sql>
+    <Parameter name="alertRule"/>
+    <Parameter name="client"/>
+  </SqlMethod>
+  <SqlMethod name="existsAlert" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT COUNT(*) AS EXISTING
+       FROM AD_ALERT
+       WHERE AD_ALERTRULE_ID = ?
+       AND REFERENCEKEY_ID = ?
+       AND ISFIXED = 'N'
+      ]]>
+    </Sql>
+    <Parameter name="alertRule"/>
+    <Parameter name="order"/>
+  </SqlMethod>
+  <SqlMethod name="getAlertRuleId" type="preparedStatement" return="string">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT MAX(ad_alertrule_id) AS name
+       FROM AD_ALERTRULE
+       WHERE NAME LIKE ?
+         AND ISACTIVE = 'Y'
+         AND AD_CLIENT_ID = ?
+      ]]></Sql>
+    <Parameter name="name"/>
+    <Parameter name="client"/>
+  </SqlMethod>  
+  <SqlMethod name="getRoleId" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+       SELECT distinct ad_role_id
+       FROM ad_window_access
+       WHERE ad_window_id = ?
+       AND AD_CLIENT_ID = ?
+         AND ISACTIVE = 'Y'
+      ]]></Sql>
+    <Parameter name="window"/>
+    <Parameter name="clientId"/>
+  </SqlMethod>
+  <SqlMethod name="insertAlertRule" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+      INSERT INTO AD_ALERTRULE (
+        AD_ALERTRULE_ID, AD_CLIENT_ID, AD_ORG_ID,ISACTIVE,
+        CREATED, CREATEDBY,  UPDATED, UPDATEDBY,
+        NAME, AD_TAB_ID, FILTERCLAUSE, TYPE,
+        SQL
+      ) VALUES (
+        get_uuid(), ?, '0', 'Y',
+        now(), '100', now(), '100',
+        ?, ?, '', 'E',
+        ?
+      )
+    ]]></Sql>
+    <Parameter name="clientId"/>
+    <Parameter name="name"/>
+    <Parameter name="tabId"/>
+    <Parameter name="sql"/>
+  </SqlMethod>
+  <SqlMethod name="insertAlert" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![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 (
+        get_uuid(), ?, ?, 'Y',
+        NOW(), '0', NOW(), '0',
+        ?, ?, ?, ?)
+      ]]>
+    </Sql>
+    <Parameter name="client"/>
+    <Parameter name="org"/>
+    <Parameter name="description" />
+    <Parameter name="adAlertRuleId" />
+    <Parameter name="recordId" />
+    <Parameter name="referencekey_id" />
+  </SqlMethod>
+  <SqlMethod name="insertAlertRecipient" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+    INSERT INTO ad_alertrecipient(
+            ad_user_id, ad_client_id, ad_org_id, isactive, created, createdby, 
+            updated, updatedby, ad_alertrecipient_id, ad_alertrule_id, ad_role_id, 
+            sendemail)
+    VALUES (null, ?, ?, 'Y', now(), '100', 
+            now(), '100', get_uuid(), ?, ?, 
+            'N')
+      ]]>
+    </Sql>
+    <Parameter name="client"/>
+    <Parameter name="org"/>
+    <Parameter name="adAlertRuleId" />
+    <Parameter name="role" />
+  </SqlMethod>  
+</SqlClass>
--- a/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdateReconciliationStatementProcessedValueData.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdateReconciliationStatementProcessedValueData.java	Wed Sep 03 16:32:14 2014 +0200
@@ -10,8 +10,6 @@
 import org.openbravo.data.FieldProvider;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.data.UtilSql;
-import org.openbravo.service.db.QueryTimeOutUtil;
-import org.openbravo.database.SessionInfo;
 import java.util.*;
 
 class UpdateReconciliationStatementProcessedValueData implements FieldProvider {
@@ -33,18 +31,10 @@
  }
 
   public static UpdateReconciliationStatementProcessedValueData[] select(ConnectionProvider connectionProvider)    throws ServletException {
-    return select((String)null, connectionProvider, 0, 0);
-  }
-
-  public static UpdateReconciliationStatementProcessedValueData[] select(String queryType, ConnectionProvider connectionProvider)    throws ServletException {
-    return select(queryType, connectionProvider, 0, 0);
+    return select(connectionProvider, 0, 0);
   }
 
   public static UpdateReconciliationStatementProcessedValueData[] select(ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)    throws ServletException {
-    return select((String)null, connectionProvider);
-  }
-
-  public static UpdateReconciliationStatementProcessedValueData[] select(String queryType, ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)    throws ServletException {
     String strSql = "";
     strSql = strSql + 
       "        select 1 as name from dual";
@@ -55,11 +45,6 @@
 
     try {
     st = connectionProvider.getPreparedStatement(strSql);
-      String profile = queryType;
-      if (profile == null || profile.isEmpty()) {
-        profile = SessionInfo.getQueryProfile();
-      }
-      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, profile);
 
       result = st.executeQuery();
       long countRecord = 0;
@@ -99,10 +84,6 @@
   }
 
   public static int updateFinancialAccount(ConnectionProvider connectionProvider)    throws ServletException {
-    return updateFinancialAccount((String)null, connectionProvider);
-  }
-
-  public static int updateFinancialAccount(String queryType, ConnectionProvider connectionProvider)    throws ServletException {
     String strSql = "";
     strSql = strSql + 
       "        UPDATE FIN_FINANCIAL_ACCOUNT SET EM_APRM_MatchTrans_Force = em_aprm_matchtransactions";
@@ -112,11 +93,6 @@
 
     try {
     st = connectionProvider.getPreparedStatement(strSql);
-      String profile = queryType;
-      if (profile == null || profile.isEmpty()) {
-        profile = SessionInfo.getQueryProfile();
-      }
-      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, profile);
 
       updateCount = st.executeUpdate();
     } catch(SQLException e){
@@ -136,10 +112,6 @@
   }
 
   public static int updateStatement(ConnectionProvider connectionProvider)    throws ServletException {
-    return updateStatement((String)null, connectionProvider);
-  }
-
-  public static int updateStatement(String queryType, ConnectionProvider connectionProvider)    throws ServletException {
     String strSql = "";
     strSql = strSql + 
       "        UPDATE FIN_BANKSTATEMENT SET em_aprm_process_bs_force = em_aprm_process_bs ";
@@ -149,11 +121,6 @@
 
     try {
     st = connectionProvider.getPreparedStatement(strSql);
-      String profile = queryType;
-      if (profile == null || profile.isEmpty()) {
-        profile = SessionInfo.getQueryProfile();
-      }
-      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, profile);
 
       updateCount = st.executeUpdate();
     } catch(SQLException e){
@@ -173,24 +140,15 @@
   }
 
   public static int updateReconciliation(ConnectionProvider connectionProvider)    throws ServletException {
-    return updateReconciliation((String)null, connectionProvider);
-  }
-
-  public static int updateReconciliation(String queryType, ConnectionProvider connectionProvider)    throws ServletException {
     String strSql = "";
     strSql = strSql + 
-      "        UPDATE FIN_BANKSTATEMENT SET em_aprm_process_rec_force = em_aprm_process_rec ";
+      "        UPDATE FIN_RECONCILIATION SET EM_APRM_Process_Rec_Force = em_aprm_process_rec ";
 
     int updateCount = 0;
     PreparedStatement st = null;
 
     try {
     st = connectionProvider.getPreparedStatement(strSql);
-      String profile = queryType;
-      if (profile == null || profile.isEmpty()) {
-        profile = SessionInfo.getQueryProfile();
-      }
-      QueryTimeOutUtil.getInstance().setQueryTimeOut(st, profile);
 
       updateCount = st.executeUpdate();
     } catch(SQLException e){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/WrongPaymentsFromJournalLineData.java	Wed Sep 03 16:32:14 2014 +0200
@@ -0,0 +1,421 @@
+//Sqlc generated V1.O00-1
+package org.openbravo.advpaymentmngt.modulescript;
+
+import java.sql.*;
+
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.data.FieldProvider;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.data.UtilSql;
+import java.util.*;
+
+class WrongPaymentsFromJournalLineData implements FieldProvider {
+static Logger log4j = Logger.getLogger(WrongPaymentsFromJournalLineData.class);
+  private String InitRecordNumber="0";
+  public String adClientId;
+  public String paymentinfo;
+  public String finPaymentId;
+  public String adOrgId;
+  public String isreceipt;
+  public String adRoleId;
+  public String adAlertruleId;
+  public String adAlertId;
+
+  public String getInitRecordNumber() {
+    return InitRecordNumber;
+  }
+
+  public String getField(String fieldName) {
+    if (fieldName.equalsIgnoreCase("ad_client_id") || fieldName.equals("adClientId"))
+      return adClientId;
+    else if (fieldName.equalsIgnoreCase("paymentinfo"))
+      return paymentinfo;
+    else if (fieldName.equalsIgnoreCase("fin_payment_id") || fieldName.equals("finPaymentId"))
+      return finPaymentId;
+    else if (fieldName.equalsIgnoreCase("ad_org_id") || fieldName.equals("adOrgId"))
+      return adOrgId;
+    else if (fieldName.equalsIgnoreCase("isreceipt"))
+      return isreceipt;
+    else if (fieldName.equalsIgnoreCase("ad_role_id") || fieldName.equals("adRoleId"))
+      return adRoleId;
+    else if (fieldName.equalsIgnoreCase("ad_alertrule_id") || fieldName.equals("adAlertruleId"))
+      return adAlertruleId;
+    else if (fieldName.equalsIgnoreCase("ad_alert_id") || fieldName.equals("adAlertId"))
+      return adAlertId;
+   else {
+     log4j.debug("Field does not exist: " + fieldName);
+     return null;
+   }
+ }
+
+  public static WrongPaymentsFromJournalLineData[] select(ConnectionProvider connectionProvider)    throws ServletException {
+    return select(connectionProvider, 0, 0);
+  }
+
+  public static WrongPaymentsFromJournalLineData[] select(ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "      select distinct p.ad_client_id, ad_column_identifier('FIN_Payment', p.fin_payment_id, 'en_US') as paymentinfo, " +
+      "      p.fin_payment_id, p.ad_org_id,  p.isreceipt, '' as ad_role_id, '' as ad_alertrule_id, '' as ad_alert_id " +
+      "      from fin_payment p left join gl_journalline jl on jl.fin_payment_id = p.fin_payment_id " +
+      "      where abs(jl.amtsourcedr-jl.amtsourcecr) != p.amount " +
+      "      order by 1, 2";
+
+    ResultSet result;
+    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
+    PreparedStatement st = null;
+
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+
+      result = st.executeQuery();
+      long countRecord = 0;
+      long countRecordSkip = 1;
+      boolean continueResult = true;
+      while(countRecordSkip < firstRegister && continueResult) {
+        continueResult = result.next();
+        countRecordSkip++;
+      }
+      while(continueResult && result.next()) {
+        countRecord++;
+        WrongPaymentsFromJournalLineData objectWrongPaymentsFromJournalLineData = new WrongPaymentsFromJournalLineData();
+        objectWrongPaymentsFromJournalLineData.adClientId = UtilSql.getValue(result, "ad_client_id");
+        objectWrongPaymentsFromJournalLineData.paymentinfo = UtilSql.getValue(result, "paymentinfo");
+        objectWrongPaymentsFromJournalLineData.finPaymentId = UtilSql.getValue(result, "fin_payment_id");
+        objectWrongPaymentsFromJournalLineData.adOrgId = UtilSql.getValue(result, "ad_org_id");
+        objectWrongPaymentsFromJournalLineData.isreceipt = UtilSql.getValue(result, "isreceipt");
+        objectWrongPaymentsFromJournalLineData.adRoleId = UtilSql.getValue(result, "ad_role_id");
+        objectWrongPaymentsFromJournalLineData.adAlertruleId = UtilSql.getValue(result, "ad_alertrule_id");
+        objectWrongPaymentsFromJournalLineData.adAlertId = UtilSql.getValue(result, "ad_alert_id");
+        objectWrongPaymentsFromJournalLineData.InitRecordNumber = Integer.toString(firstRegister);
+        vector.addElement(objectWrongPaymentsFromJournalLineData);
+        if (countRecord >= numberRegisters && numberRegisters != 0) {
+          continueResult = false;
+        }
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    WrongPaymentsFromJournalLineData objectWrongPaymentsFromJournalLineData[] = new WrongPaymentsFromJournalLineData[vector.size()];
+    vector.copyInto(objectWrongPaymentsFromJournalLineData);
+    return(objectWrongPaymentsFromJournalLineData);
+  }
+
+  public static boolean existsAlertRule(ConnectionProvider connectionProvider, String alertRule, String client)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "       SELECT COUNT(*) AS EXISTING" +
+      "       FROM AD_ALERTRULE" +
+      "       WHERE NAME = ?" +
+      "         AND ISACTIVE = 'Y'" +
+      "         AND AD_CLIENT_ID = ?";
+
+    ResultSet result;
+    boolean boolReturn = false;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, alertRule);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, client);
+
+      result = st.executeQuery();
+      if(result.next()) {
+        boolReturn = !UtilSql.getValue(result, "existing").equals("0");
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(boolReturn);
+  }
+
+  public static boolean existsAlert(ConnectionProvider connectionProvider, String alertRule, String order)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "       SELECT COUNT(*) AS EXISTING" +
+      "       FROM AD_ALERT" +
+      "       WHERE AD_ALERTRULE_ID = ?" +
+      "       AND REFERENCEKEY_ID = ?" +
+      "       AND ISFIXED = 'N'";
+
+    ResultSet result;
+    boolean boolReturn = false;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, alertRule);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, order);
+
+      result = st.executeQuery();
+      if(result.next()) {
+        boolReturn = !UtilSql.getValue(result, "existing").equals("0");
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(boolReturn);
+  }
+
+  public static String getAlertRuleId(ConnectionProvider connectionProvider, String name, String client)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "       SELECT MAX(ad_alertrule_id) AS name" +
+      "       FROM AD_ALERTRULE" +
+      "       WHERE NAME LIKE ?" +
+      "         AND ISACTIVE = 'Y'" +
+      "         AND AD_CLIENT_ID = ?";
+
+    ResultSet result;
+    String strReturn = null;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, name);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, client);
+
+      result = st.executeQuery();
+      if(result.next()) {
+        strReturn = UtilSql.getValue(result, "name");
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(strReturn);
+  }
+
+  public static WrongPaymentsFromJournalLineData[] getRoleId(ConnectionProvider connectionProvider, String window, String clientId)    throws ServletException {
+    return getRoleId(connectionProvider, window, clientId, 0, 0);
+  }
+
+  public static WrongPaymentsFromJournalLineData[] getRoleId(ConnectionProvider connectionProvider, String window, String clientId, int firstRegister, int numberRegisters)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "       SELECT distinct ad_role_id" +
+      "       FROM ad_window_access" +
+      "       WHERE ad_window_id = ?" +
+      "       AND AD_CLIENT_ID = ?" +
+      "         AND ISACTIVE = 'Y'";
+
+    ResultSet result;
+    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, window);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, clientId);
+
+      result = st.executeQuery();
+      long countRecord = 0;
+      long countRecordSkip = 1;
+      boolean continueResult = true;
+      while(countRecordSkip < firstRegister && continueResult) {
+        continueResult = result.next();
+        countRecordSkip++;
+      }
+      while(continueResult && result.next()) {
+        countRecord++;
+        WrongPaymentsFromJournalLineData objectWrongPaymentsFromJournalLineData = new WrongPaymentsFromJournalLineData();
+        objectWrongPaymentsFromJournalLineData.adRoleId = UtilSql.getValue(result, "ad_role_id");
+        objectWrongPaymentsFromJournalLineData.InitRecordNumber = Integer.toString(firstRegister);
+        vector.addElement(objectWrongPaymentsFromJournalLineData);
+        if (countRecord >= numberRegisters && numberRegisters != 0) {
+          continueResult = false;
+        }
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    WrongPaymentsFromJournalLineData objectWrongPaymentsFromJournalLineData[] = new WrongPaymentsFromJournalLineData[vector.size()];
+    vector.copyInto(objectWrongPaymentsFromJournalLineData);
+    return(objectWrongPaymentsFromJournalLineData);
+  }
+
+  public static int insertAlertRule(ConnectionProvider connectionProvider, String clientId, String name, String tabId, String sql)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "      INSERT INTO AD_ALERTRULE (" +
+      "        AD_ALERTRULE_ID, AD_CLIENT_ID, AD_ORG_ID,ISACTIVE," +
+      "        CREATED, CREATEDBY,  UPDATED, UPDATEDBY," +
+      "        NAME, AD_TAB_ID, FILTERCLAUSE, TYPE," +
+      "        SQL" +
+      "      ) VALUES (" +
+      "        get_uuid(), ?, '0', 'Y'," +
+      "        now(), '100', now(), '100'," +
+      "        ?, ?, '', 'E'," +
+      "        ?" +
+      "      )";
+
+    int updateCount = 0;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, clientId);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, name);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, tabId);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, sql);
+
+      updateCount = st.executeUpdate();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(updateCount);
+  }
+
+  public static int insertAlert(ConnectionProvider connectionProvider, String client, String org, String description, String adAlertRuleId, String recordId, String referencekey_id)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "      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 (" +
+      "        get_uuid(), ?, ?, 'Y'," +
+      "        NOW(), '0', NOW(), '0'," +
+      "        ?, ?, ?, ?)";
+
+    int updateCount = 0;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, client);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, org);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, description);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, adAlertRuleId);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, recordId);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, referencekey_id);
+
+      updateCount = st.executeUpdate();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(updateCount);
+  }
+
+  public static int insertAlertRecipient(ConnectionProvider connectionProvider, String client, String org, String adAlertRuleId, String role)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "    INSERT INTO ad_alertrecipient(" +
+      "            ad_user_id, ad_client_id, ad_org_id, isactive, created, createdby, " +
+      "            updated, updatedby, ad_alertrecipient_id, ad_alertrule_id, ad_role_id, " +
+      "            sendemail)" +
+      "    VALUES (null, ?, ?, 'Y', now(), '100', " +
+      "            now(), '100', get_uuid(), ?, ?, " +
+      "            'N')";
+
+    int updateCount = 0;
+    PreparedStatement st = null;
+
+    int iParameter = 0;
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, client);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, org);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, adAlertRuleId);
+      iParameter++; UtilSql.setValue(st, iParameter, 12, null, role);
+
+      updateCount = st.executeUpdate();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(updateCount);
+  }
+}
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -154,7 +154,7 @@
           errorMessage.put("severity", "error");
           errorMessage.put("text", e.getMessage());
           jsonResponse.put("message", errorMessage);
-          return errorMessage;
+          return jsonResponse;
         }
       }
       payment.setAmount(new BigDecimal(strActualPayment));
@@ -172,7 +172,7 @@
           || strAction.equals("PPW")) {
 
         OBError message = processPayment(payment, strAction, strDifferenceAction, differenceAmount,
-            exchangeRate);
+            exchangeRate, jsonparams);
         JSONObject errorMessage = new JSONObject();
         errorMessage.put("severity", message.getType().toLowerCase());
         errorMessage.put("title", message.getTitle());
@@ -329,6 +329,7 @@
         creditPayment.setDescription(truncateDescription);
         // Set Used Credit = Amount + Previous used credit introduced by the user
         creditPayment.setUsedCredit(usedCreditAmt.add(creditPayment.getUsedCredit()));
+        ;
         FIN_PaymentProcess.linkCreditPayment(payment, usedCreditAmt, creditPayment);
         OBDal.getInstance().save(creditPayment);
       }
@@ -468,7 +469,7 @@
   }
 
   private OBError processPayment(FIN_Payment payment, String strAction, String strDifferenceAction,
-      BigDecimal refundAmount, BigDecimal exchangeRate) throws Exception {
+      BigDecimal refundAmount, BigDecimal exchangeRate, JSONObject jsonparams) throws Exception {
     ConnectionProvider conn = new DalConnectionProvider(true);
     VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
 
@@ -493,6 +494,11 @@
     if (!"Error".equalsIgnoreCase(message.getType())) {
       message.setMessage(strNewPaymentMessage + " " + message.getMessage());
       message.setType(message.getType().toLowerCase());
+    } else {
+      conn = new DalConnectionProvider(true);
+      OBDal.getInstance().getSession().clear();
+      payment = OBDal.getInstance().get(FIN_Payment.class, payment.getId());
+      addCredit(payment, jsonparams);
     }
     if (!strDifferenceAction.equals("refund")) {
       return message;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java	Wed Sep 03 16:32:14 2014 +0200
@@ -107,7 +107,8 @@
     HashMap<String, String> map = new HashMap<String, String>();
     map.put("DifferentPaymentMethod", "false");
     map.put("Count", "0");
-    JSONArray selectedLines = jsonRequest.getJSONArray("_selection");
+    JSONObject grid = jsonRequest.getJSONObject("_params").getJSONObject("grid");
+    JSONArray selectedLines = grid.getJSONArray("_selection");
     final String strPaymentProposalId = jsonRequest.getString("Fin_Payment_Proposal_ID");
     FIN_PaymentProposal paymentProposal = OBDal.getInstance().get(FIN_PaymentProposal.class,
         strPaymentProposalId);
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2013 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -871,9 +871,6 @@
     OBContext.setAdminMode();
     try {
       bsline = OBDal.getInstance().get(FIN_BankStatementLine.class, bsline.getId());
-      // merge if the bank statement line was split before
-      mergeBankStatementLine(bsline);
-
       FIN_FinaccTransaction finTrans = bsline.getFinancialAccountTransaction();
       if (finTrans == null) {
         String strTransactionId = vars.getStringParameter("inpFinancialTransactionId_"
@@ -894,6 +891,9 @@
       OBDal.getInstance().save(bsline);
       // OBDal.getInstance().flush();
 
+      // merge if the bank statement line was split before
+      mergeBankStatementLine(bsline);
+
       if (finTrans != null) {
         if (finTrans.getFinPayment() != null) {
           finTrans.getFinPayment().setStatus(
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/MatchTransactionDao.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/MatchTransactionDao.java	Wed Sep 03 16:32:14 2014 +0200
@@ -26,6 +26,8 @@
 
 import javax.servlet.ServletException;
 
+import org.hibernate.Query;
+import org.hibernate.Session;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.ProjectionList;
 import org.hibernate.criterion.Projections;
@@ -606,15 +608,39 @@
     OBContext.setAdminMode(false);
     try {
       BigDecimal endingBalance = reconciliation.getAccount().getInitialBalance();
-      endingBalance = endingBalance
-          .add(getBSLAmount(reconciliation, reconciliation.getEndingDate()));
+      endingBalance = endingBalance.add(getBSLAmount(reconciliation)).add(
+          getManualReconciliationAmount(reconciliation));
       return endingBalance;
     } finally {
       OBContext.restorePreviousMode();
     }
   }
 
-  private static BigDecimal getBSLAmount(FIN_Reconciliation reconciliation, Date date) {
+  private static BigDecimal getManualReconciliationAmount(FIN_Reconciliation reconciliation) {
+    BigDecimal total = BigDecimal.ZERO;
+    OBContext.setAdminMode(false);
+    try {
+      final StringBuilder hqlString = new StringBuilder();
+      hqlString.append("select coalesce(sum(e.depositAmount-e.paymentAmount),0)");
+      hqlString.append(" from FIN_Finacc_Transaction as e");
+      hqlString.append(" where e.account.id = :account");
+      hqlString.append(" and e.processed = true");
+      hqlString.append(" and e.reconciliation is not null");
+      hqlString
+          .append(" and not exists (select 1 from FIN_BankStatementLine as bsl where bsl.financialAccountTransaction = e)");
+      hqlString.append(" and e.transactionDate <= :date");
+      final Session session = OBDal.getInstance().getSession();
+      final Query query = session.createQuery(hqlString.toString());
+      query.setParameter("account", reconciliation.getAccount().getId());
+      query.setParameter("date", reconciliation.getEndingDate());
+      total = (BigDecimal) query.uniqueResult();
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    return total;
+  }
+
+  private static BigDecimal getBSLAmount(FIN_Reconciliation reconciliation) {
     BigDecimal total = BigDecimal.ZERO;
     OBContext.setAdminMode(false);
     try {
@@ -626,7 +652,8 @@
       obcBsl.add(Restrictions.eq("bs." + FIN_BankStatement.PROPERTY_ACCOUNT,
           reconciliation.getAccount()));
       obcBsl.add(Restrictions.eq("bs." + FIN_BankStatement.PROPERTY_PROCESSED, true));
-      obcBsl.add(Restrictions.le(FIN_BankStatementLine.PROPERTY_TRANSACTIONDATE, date));
+      obcBsl.add(Restrictions.le(FIN_BankStatementLine.PROPERTY_TRANSACTIONDATE,
+          reconciliation.getEndingDate()));
       ProjectionList projections = Projections.projectionList();
       projections.add(Projections.sum(FIN_BankStatementLine.PROPERTY_CRAMOUNT));
       projections.add(Projections.sum(FIN_BankStatementLine.PROPERTY_DRAMOUNT));
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,7 +19,6 @@
 package org.openbravo.advpaymentmngt.filterexpression;
 
 import java.math.BigDecimal;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -30,8 +29,9 @@
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
 import org.openbravo.dal.service.OBDal;
-import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
@@ -68,6 +68,8 @@
 
   abstract String getOrganization(Map<String, String> requestMap) throws JSONException;
 
+  abstract String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException;
+
   protected abstract long getSeq();
 
   String getDefaultCurrencyTo(Map<String, String> requestMap) throws JSONException {
@@ -134,19 +136,30 @@
       BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class,
           strBPartnerId);
       boolean isSOTrx = "Y".equals(getDefaultIsSOTrx(requestMap));
-      if (isSOTrx && businessPartner.getAccount() != null) {
-        return businessPartner.getAccount().getId();
-      } else if (!isSOTrx && businessPartner.getPOFinancialAccount() != null) {
-        return businessPartner.getPOFinancialAccount().getId();
+      if (context.has("inpadClientId") && context.has("inpadOrgId")) {
+        final OrganizationStructureProvider osp = OBContext.getOBContext()
+            .getOrganizationStructureProvider(context.getString("inpadClientId"));
+        if (isSOTrx && businessPartner.getAccount() != null) {
+          if (osp.isInNaturalTree(businessPartner.getAccount().getOrganization(), OBDal
+              .getInstance().get(Organization.class, context.getString("inpadOrgId")))) {
+            return businessPartner.getAccount().getId();
+          } else {
+            return "";
+          }
+
+        } else if (!isSOTrx && businessPartner.getPOFinancialAccount() != null) {
+          if (osp.isInNaturalTree(businessPartner.getPOFinancialAccount().getOrganization(), OBDal
+              .getInstance().get(Organization.class, context.getString("inpadOrgId")))) {
+            return businessPartner.getPOFinancialAccount().getId();
+          } else {
+            return "";
+          }
+        }
       }
     }
     return null;
   }
 
-  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
-    return OBDateUtils.formatDate(new Date());
-  }
-
   String getDefaultPaymentMethod(Map<String, String> requestMap) throws JSONException {
     JSONObject context = new JSONObject(requestMap.get("context"));
     if (context.has("inpfinPaymentmethodId")
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -26,6 +26,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 
 @ComponentProvider.Qualifier(APRMConstants.PAYMENT_IN_WINDOW_ID)
@@ -143,4 +144,10 @@
     return getPayment(requestMap).getOrganization().getId();
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    // Payment Date of the current payment
+    return OBDateUtils.formatDate(getPayment(requestMap).getPaymentDate());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -26,6 +26,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 
 @ComponentProvider.Qualifier(APRMConstants.PAYMENT_OUT_WINDOW_ID)
@@ -154,4 +155,10 @@
     return getPayment(requestMap).getOrganization().getId();
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    // Payment Date of the current payment
+    return OBDateUtils.formatDate(getPayment(requestMap).getPaymentDate());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.advpaymentmngt.filterexpression;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONException;
@@ -26,6 +27,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.common.invoice.Invoice;
 
 @ComponentProvider.Qualifier(APRMConstants.PURCHASE_INVOICE_WINDOW_ID)
@@ -127,4 +129,9 @@
     return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    return OBDateUtils.formatDate(new Date());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.advpaymentmngt.filterexpression;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONException;
@@ -26,6 +27,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.common.order.Order;
 
 @ComponentProvider.Qualifier(APRMConstants.PURCHASE_ORDER_WINDOW_ID)
@@ -131,4 +133,9 @@
     return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    return OBDateUtils.formatDate(new Date());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.advpaymentmngt.filterexpression;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONException;
@@ -26,6 +27,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.common.invoice.Invoice;
 
 @ComponentProvider.Qualifier(APRMConstants.SALES_INVOICE_WINDOW_ID)
@@ -127,4 +129,9 @@
     return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    return OBDateUtils.formatDate(new Date());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDefaultValues.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDefaultValues.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.advpaymentmngt.filterexpression;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONException;
@@ -26,6 +27,7 @@
 import org.openbravo.advpaymentmngt.utility.APRMConstants;
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.model.common.order.Order;
 
 @ComponentProvider.Qualifier(APRMConstants.SALES_ORDER_WINDOW_ID)
@@ -131,4 +133,9 @@
     return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
   }
 
+  @Override
+  String getDefaultPaymentDate(Map<String, String> requestMap) throws JSONException {
+    return OBDateUtils.formatDate(new Date());
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Wed Sep 03 16:32:14 2014 +0200
@@ -1138,7 +1138,11 @@
    *          Amount of the Payment Schedule Detail or Payment Detail
    * @param writeOffAmount
    *          Write off amount, null or 0 if not applicable.
+   * 
+   * @Deprecated This method doesn't support Cash VAT flow, so it's better to use
+   *             {@link #updatePaymentDetail(FIN_PaymentScheduleDetail, FIN_Payment, BigDecimal, boolean)}
    */
+  @Deprecated
   public static void updatePaymentScheduleAmounts(FIN_PaymentSchedule paymentSchedule,
       BigDecimal amount, BigDecimal writeOffAmount) {
     updatePaymentScheduleAmounts(null, paymentSchedule, amount, writeOffAmount);
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournalLine.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2013 Openbravo SLU
+ * All portions are Copyright (C) 2013-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -54,7 +54,7 @@
     String strMessageType = "";
     StringBuilder strMessageResult = new StringBuilder();
     String strTitle = "";
-
+    OBContext.setAdminMode(true);
     try {
 
       // retrieve the parameters from the bundle
@@ -67,8 +67,8 @@
       BusinessPartner bPartner = journalLine.getBusinessPartner();
       GLItem glItem = journalLine.getGLItem();
       Date date = journalLine.getPaymentDate();
-      boolean isReceipt = journalLine.getDebit().subtract(journalLine.getCredit())
-          .compareTo(BigDecimal.ZERO) > 0;
+      boolean isReceipt = journalLine.getDebit().subtract(journalLine.getCredit()).compareTo(
+          BigDecimal.ZERO) > 0;
 
       // Check restrictions
       OBContext.setAdminMode(false);
@@ -111,16 +111,18 @@
           (isReceipt) ? "ARR" : "APP", (isReceipt) ? "AR Receipt" : "AP Payment");
 
       // Generate Payment
-      FIN_Payment payment = dao.getNewPayment(isReceipt, journalLine.getOrganization(),
-          dao.getObject(DocumentType.class, strDocTypeId), strPaymentDocumentNo, bPartner,
-          paymentMethod, financialAccount, journalLine.getDebit().subtract(journalLine.getCredit())
-              .abs().toString(), date, null, journalLine.getCurrency(), null, null);
+      FIN_Payment payment = dao.getNewPayment(isReceipt, journalLine.getOrganization(), dao
+          .getObject(DocumentType.class, strDocTypeId), strPaymentDocumentNo, bPartner,
+          paymentMethod, financialAccount, journalLine.getForeignCurrencyDebit().subtract(
+              journalLine.getForeignCurrencyCredit()).abs().toString(), date, null, journalLine
+              .getCurrency(), null, null);
 
       // Add Payment Details
-      FIN_AddPayment.saveGLItem(payment, journalLine.getDebit().subtract(journalLine.getCredit())
-          .abs(), glItem, bPartner, journalLine.getProduct(), journalLine.getProject(),
-          journalLine.getSalesCampaign(), journalLine.getActivity(), journalLine.getSalesRegion(),
-          journalLine.getCostCenter(), journalLine.getStDimension(), journalLine.getNdDimension());
+      FIN_AddPayment.saveGLItem(payment, journalLine.getForeignCurrencyDebit().subtract(
+          journalLine.getForeignCurrencyCredit()).abs(), glItem, bPartner,
+          journalLine.getProduct(), journalLine.getProject(), journalLine.getSalesCampaign(),
+          journalLine.getActivity(), journalLine.getSalesRegion(), journalLine.getCostCenter(),
+          journalLine.getStDimension(), journalLine.getNdDimension());
 
       OBDal.getInstance().flush();
 
@@ -142,10 +144,8 @@
         strMessageType = "Success";
       }
       strMessageResult.append("@Payment@ ").append(payment.getDocumentNo());
-      strMessageResult
-          .append(" (")
-          .append(
-              payment.getBusinessPartner() != null ? payment.getBusinessPartner().getName() : "")
+      strMessageResult.append(" (").append(
+          payment.getBusinessPartner() != null ? payment.getBusinessPartner().getName() : "")
           .append(")");
       if (!"".equals(message.getMessage()))
         strMessageResult.append(": ").append(message.getMessage());
@@ -168,6 +168,8 @@
       msg.setMessage(e.getMessage());
       msg.setTitle("@Error@");
       bundle.setResult(msg);
+    } finally {
+      OBContext.restorePreviousMode();
     }
 
   }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,7 +19,9 @@
 package org.openbravo.advpaymentmngt.process;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -34,6 +36,7 @@
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
@@ -44,7 +47,9 @@
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.ConversionRate;
 import org.openbravo.model.common.currency.ConversionRateDoc;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.model.financialmgmt.accounting.FIN_FinancialAccountAccounting;
@@ -57,7 +62,6 @@
 import org.openbravo.model.financialmgmt.payment.FIN_Payment_Credit;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
 import org.openbravo.model.financialmgmt.payment.PaymentExecutionProcess;
-import org.openbravo.model.pricing.pricelist.PriceList;
 import org.openbravo.scheduling.ProcessBundle;
 import org.openbravo.service.db.DalConnectionProvider;
 
@@ -302,17 +306,19 @@
               OBDal.getInstance().rollbackAndClose();
               return;
             }
-            PriceList priceList = payment.isReceipt() ? businessPartner.getPriceList()
-                : businessPartner.getPurchasePricelist();
-            if (!payment.getCurrency().getId()
-                .equals(priceList != null ? priceList.getCurrency().getId() : "")) {
+            String currency = null;
+            if (businessPartner.getCurrency() == null) {
+              currency = payment.getCurrency().getId();
+              businessPartner.setCurrency(payment.getCurrency());
+            } else {
+              currency = businessPartner.getCurrency().getId();
+            }
+            if (!payment.getCurrency().getId().equals(currency)) {
               msg.setType("Error");
               msg.setTitle(Utility.messageBD(conProvider, "Error", language));
               msg.setMessage(String.format(
                   Utility.parseTranslation(conProvider, vars, language, "@APRM_CreditCurrency@"),
-                  priceList != null ? priceList.getCurrency().getISOCode() : Utility
-                      .parseTranslation(conProvider, vars, language,
-                          "@APRM_CreditNoPricelistCurrency@")));
+                  businessPartner.getCurrency().getISOCode()));
               bundle.setResult(msg);
               OBDal.getInstance().rollbackAndClose();
               return;
@@ -402,10 +408,44 @@
                         .getInvoice().getBusinessPartner();
 
                     // Payments update credit opposite to invoices
+                    BigDecimal paidAmount = BigDecimal.ZERO;
+                    Invoice invoiceForConversion = paymentScheduleDetail
+                        .getInvoicePaymentSchedule() != null ? paymentScheduleDetail
+                        .getInvoicePaymentSchedule().getInvoice() : null;
+                    paidAmount = BigDecimal.ZERO;
+                    String fromCurrency = payment.getCurrency().getId();
+                    String toCurrency = businessPartner.getCurrency().getId();
+                    if (!fromCurrency.equals(toCurrency)) {
+                      BigDecimal exchangeRate = BigDecimal.ZERO;
+                      // check at invoice document level
+                      List<ConversionRateDoc> conversionRateDocumentForInvoice = getConversionRateDocumentForInvoice(
+                          invoiceForConversion, isReceipt);
+                      if (conversionRateDocumentForInvoice.size() > 0) {
+                        exchangeRate = conversionRateDocumentForInvoice.get(0).getRate();
+                      } else {
+                        // global
+                        exchangeRate = getConversionRate(payment.getOrganization().getId(),
+                            fromCurrency, toCurrency,
+                            invoiceForConversion != null ? invoiceForConversion.getInvoiceDate()
+                                : payment.getPaymentDate());
+                      }
+                      if (exchangeRate == BigDecimal.ZERO) {
+                        msg.setType("Error");
+                        msg.setTitle(Utility.messageBD(conProvider, "Error", language));
+                        msg.setMessage(Utility.parseTranslation(conProvider, vars, language,
+                            "@NoCurrencyConversion@"));
+                        bundle.setResult(msg);
+                        OBDal.getInstance().rollbackAndClose();
+                        return;
+                      }
+                      paidAmount = amount.multiply(exchangeRate);
+                    } else {
+                      paidAmount = amount;
+                    }
                     if (isReceipt) {
-                      decreaseCustomerCredit(businessPartner, amount);
+                      decreaseCustomerCredit(businessPartner, paidAmount);
                     } else {
-                      increaseCustomerCredit(businessPartner, amount);
+                      increaseCustomerCredit(businessPartner, paidAmount);
                     }
                     FIN_AddPayment.updatePaymentScheduleAmounts(paymentDetail,
                         paymentScheduleDetail.getInvoicePaymentSchedule(),
@@ -725,14 +765,20 @@
         OBContext.setAdminMode();
         try {
           BusinessPartner businessPartner = payment.getBusinessPartner();
-          // When credit is used (consumed) we compensate so_creditused as this amount is already
-          // included in the payment details. Credit consumed should not affect to so_creditused
-          if (payment.getGeneratedCredit().compareTo(BigDecimal.ZERO) == 0
-              && payment.getUsedCredit().compareTo(BigDecimal.ZERO) != 0) {
-            if (isReceipt) {
-              decreaseCustomerCredit(businessPartner, payment.getUsedCredit());
-            } else {
-              increaseCustomerCredit(businessPartner, payment.getUsedCredit());
+          BigDecimal paidAmount = BigDecimal.ZERO;
+          String fromCurrency = payment.getCurrency().getId();
+          String toCurrency = "";
+          if (!(businessPartner == null)) {
+            // When credit is used (consumed) we compensate so_creditused as this amount is already
+            // included in the payment details. Credit consumed should not affect to so_creditused
+            toCurrency = businessPartner.getCurrency().getId();
+            if (payment.getGeneratedCredit().compareTo(BigDecimal.ZERO) == 0
+                && payment.getUsedCredit().compareTo(BigDecimal.ZERO) != 0) {
+              if (isReceipt) {
+                decreaseCustomerCredit(businessPartner, payment.getUsedCredit());
+              } else {
+                increaseCustomerCredit(businessPartner, payment.getUsedCredit());
+              }
             }
           }
           List<FIN_PaymentDetail> paymentDetails = payment.getFINPaymentDetailList();
@@ -790,13 +836,47 @@
                     // BP SO_CreditUsed
                     businessPartner = paymentScheduleDetail.getInvoicePaymentSchedule()
                         .getInvoice().getBusinessPartner();
-                    if (isReceipt) {
-                      increaseCustomerCredit(businessPartner, amount);
-                    } else {
-                      decreaseCustomerCredit(businessPartner, amount);
-
+                    Invoice invoiceForConversion = paymentScheduleDetail
+                        .getInvoicePaymentSchedule() != null ? paymentScheduleDetail
+                        .getInvoicePaymentSchedule().getInvoice() : null;
+                    paidAmount = BigDecimal.ZERO;
+                    fromCurrency = payment.getCurrency().getId();
+                    toCurrency = "";
+                    if (!(businessPartner == null)) {
+                      toCurrency = businessPartner.getCurrency().getId();
+                      if (!fromCurrency.equals(toCurrency)) {
+                        BigDecimal exchangeRate = BigDecimal.ZERO;
+                        // check at invoice document level
+                        List<ConversionRateDoc> conversionRateDocumentForInvoice = getConversionRateDocumentForInvoice(
+                            invoiceForConversion, isReceipt);
+                        if (conversionRateDocumentForInvoice.size() > 0) {
+                          exchangeRate = conversionRateDocumentForInvoice.get(0).getRate();
+                        } else {
+                          // global
+                          exchangeRate = getConversionRate(payment.getOrganization().getId(),
+                              fromCurrency, toCurrency,
+                              invoiceForConversion != null ? invoiceForConversion.getInvoiceDate()
+                                  : payment.getPaymentDate());
+                        }
+                        if (exchangeRate == BigDecimal.ZERO) {
+                          msg.setType("Error");
+                          msg.setTitle(Utility.messageBD(conProvider, "Error", language));
+                          msg.setMessage(Utility.parseTranslation(conProvider, vars, language,
+                              "@NoCurrencyConversion@"));
+                          bundle.setResult(msg);
+                          OBDal.getInstance().rollbackAndClose();
+                          return;
+                        }
+                        paidAmount = amount.multiply(exchangeRate);
+                      } else {
+                        paidAmount = amount;
+                      }
+                      if (isReceipt) {
+                        increaseCustomerCredit(businessPartner, paidAmount);
+                      } else {
+                        decreaseCustomerCredit(businessPartner, paidAmount);
+                      }
                     }
-
                   }
                 }
                 if (paymentScheduleDetail.getOrderPaymentSchedule() != null && restorePaidAmounts) {
@@ -1266,6 +1346,23 @@
     }
   }
 
+  private List<ConversionRateDoc> getConversionRateDocumentForInvoice(Invoice invoice,
+      boolean isReceipt) {
+    OBContext.setAdminMode(true);
+    try {
+      OBCriteria<ConversionRateDoc> obc = OBDal.getInstance().createCriteria(
+          ConversionRateDoc.class);
+      obc.add(Restrictions.eq(ConversionRateDoc.PROPERTY_CURRENCY, invoice.getCurrency()));
+      obc.add(Restrictions.eq(ConversionRateDoc.PROPERTY_TOCURRENCY, isReceipt ? invoice
+          .getBusinessPartner().getCurrency() : invoice.getBusinessPartner().getPurchasePricelist()
+          .getCurrency()));
+      obc.add(Restrictions.eq(ConversionRateDoc.PROPERTY_INVOICE, invoice));
+      return obc.list();
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
   private ConversionRateDoc insertConversionRateDocument(FIN_Payment payment) {
     OBContext.setAdminMode();
     try {
@@ -1366,4 +1463,24 @@
     return confirmation;
   }
 
+  private BigDecimal getConversionRate(String strOrgId, String strFromCurrencyId,
+      String strToCurrencyId, Date conversionDate) {
+    BigDecimal exchangeRate = BigDecimal.ZERO;
+    // Apply default conversion rate
+    int conversionRatePrecision = FIN_Utility.getConversionRatePrecision(RequestContext.get()
+        .getVariablesSecureApp());
+    Organization organization = OBDal.getInstance().get(Organization.class, strOrgId);
+    Currency fromCurrency = OBDal.getInstance().get(Currency.class, strFromCurrencyId);
+    Currency toCurrency = OBDal.getInstance().get(Currency.class, strToCurrencyId);
+    final ConversionRate conversionRate = FIN_Utility.getConversionRate(fromCurrency, toCurrency,
+        conversionDate, organization);
+    if (conversionRate != null) {
+      exchangeRate = conversionRate.getMultipleRateBy().setScale(conversionRatePrecision,
+          RoundingMode.HALF_UP);
+    } else {
+      exchangeRate = BigDecimal.ZERO;
+    }
+    return exchangeRate;
+  }
+
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Wed Sep 03 16:32:14 2014 +0200
@@ -388,8 +388,6 @@
    * @param tableName
    *          the name of the table from which the sequence will be taken if the Document Type does
    *          not have any sequence associated.
-   * @param updateNext
-   *          Flag to update the current number of the sequence
    * @return the next sequence number of the Document Type defined for the Organization and document
    *         category. Null if no sequence is found.
    */
@@ -1093,7 +1091,7 @@
     parameters.add(status);
     parameters.add((psd != null) ? psd.getId() : "");
     String result = (String) CallStoredProcedure.getInstance().call("APRM_ISPAYMENTCONFIRMED",
-        parameters, null);
+        parameters, null, false);
 
     return "Y".equals(result);
   }
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js	Wed Sep 03 16:32:14 2014 +0200
@@ -97,8 +97,8 @@
       glitemGrid = form.getItem('glitem').canvas.viewGrid,
       creditUseGrid = form.getItem('credit_to_use').canvas.viewGrid,
       overpaymentAction = form.getItem('overpayment_action'),
-      payment = form.getItem('fin_payment_id').getValue();
-
+      payment = form.getItem('fin_payment_id').getValue(),
+      issotrx = form.getItem('issotrx').getValue();
   OB.APRM.AddPayment.paymentMethodMulticurrency(view, view.theForm, !payment);
   glitemGrid.fetchData();
   creditUseGrid.fetchData();
@@ -111,6 +111,9 @@
   form.isCreditAllowed = form.getItem('received_from').getValue() !== undefined;
   OB.APRM.AddPayment.checkSingleActionAvailable(form);
   overpaymentAction.originalValueMap = isc.addProperties({}, overpaymentAction.getValueMap());
+  if (issotrx) {
+    form.focusInItem(form.getItem('actual_payment'));
+  }
 };
 
 OB.APRM.AddPayment.addNewGLItem = function (grid) {
@@ -281,8 +284,22 @@
       glitemamt = new BigDecimal(String(form.getItem('amount_gl_items').getValue() || 0)),
       orderInvoiceData = orderInvoice.data.localData,
       total = orderInvoice.data.totalRows,
-      writeoff, amt, outstandingAmount, i;
+      writeoff, amt, outstandingAmount, i, showMessageProperty, showMessage, message;
 
+  if (orderInvoice.data.cachedRows < (orderInvoice.data.totalRows)) {
+    showMessageProperty = OB.PropertyStore.get('APRM_ShowNoDistributeMsg');
+    showMessage = (showMessageProperty !== 'N' && showMessageProperty !== '"N"');
+    if (showMessage) {
+      orderInvoice.contentView.messageBar.setMessage(isc.OBMessageBar.TYPE_INFO, '<div><div class="' + OB.Styles.MessageBar.leftMsgContainerStyle + '">' + OB.I18N.getLabel('APRM_NoDistributeMsg') + '</div><div class="' + OB.Styles.MessageBar.rightMsgContainerStyle + '"><a href="#" class="' + OB.Styles.MessageBar.rightMsgTextStyle + '" onclick="' + 'window[\'' + orderInvoice.contentView.messageBar.ID + '\'].hide(); OB.PropertyStore.set(\'APRM_ShowNoDistributeMsg\', \'N\');">' + OB.I18N.getLabel('OBUIAPP_NeverShowMessageAgain') + '</a></div></div>', ' ');
+    }
+    return;
+  } else {
+	// hide the message bar if it is still showing the APRM_NoDistributeMsg message and the distribution is about to be done
+    message = orderInvoice.contentView.messageBar.text.contents;
+    if (message.contains(OB.I18N.getLabel('APRM_NoDistributeMsg'))) {
+      orderInvoice.contentView.messageBar.hide();
+    }
+  }
   // subtract glitem amount
   amount = amount.subtract(glitemamt);
   // add credit amount
@@ -417,12 +434,12 @@
 OB.APRM.AddPayment.updateInvOrderTotal = function (form, grid) {
   var totalAmt = BigDecimal.prototype.ZERO,
       amountField = grid.getFieldByColumnName('amount'),
-      selectedRecords = grid.getSelectedRecords(),
+      selectedRecords = grid.selectedIds,
       invOrdTotalItem = form.getItem('amount_inv_ords'),
       amt, i, bdAmt;
 
   for (i = 0; i < selectedRecords.length; i++) {
-    amt = grid.getEditedCell(grid.getRecordIndex(selectedRecords[i]), amountField);
+    amt = grid.getEditedCell(grid.getRecordIndex(grid.data.localData.find('id', grid.selectedIds[i])), amountField);
     bdAmt = new BigDecimal(String(amt));
     totalAmt = totalAmt.add(bdAmt);
   }
@@ -497,11 +514,11 @@
       generateCredit = new BigDecimal(String(form.getItem('generateCredit').getValue() || 0)),
       glitemtotal = new BigDecimal(String(form.getItem('amount_gl_items').getValue() || 0)),
       credit = new BigDecimal(String(form.getItem('used_credit').getValue() || 0)),
-      selectedRecords = orderInvoice.getSelectedRecords(),
+      selectedRecords = orderInvoice.selectedIds,
       actpayment, i;
   for (i = 0; i < selectedRecords.length; i++) {
-    totalAmountoutstanding = totalAmountoutstanding.add(new BigDecimal(String(orderInvoice.getEditedCell(orderInvoice.getRecordIndex(selectedRecords[i]), orderInvoice.getFieldByColumnName('outstandingAmount')))));
-    totalAmount = totalAmount.add(new BigDecimal(String(orderInvoice.getEditedCell(orderInvoice.getRecordIndex(selectedRecords[i]), orderInvoice.getFieldByColumnName('amount')))));
+    totalAmountoutstanding = totalAmountoutstanding.add(new BigDecimal(String(orderInvoice.getEditedCell(orderInvoice.getRecordIndex(orderInvoice.data.localData.find('id', orderInvoice.selectedIds[i])), orderInvoice.getFieldByColumnName('outstandingAmount')))));
+    totalAmount = totalAmount.add(new BigDecimal(String(orderInvoice.getEditedCell(orderInvoice.getRecordIndex(orderInvoice.data.localData.find('id', orderInvoice.selectedIds[i])), orderInvoice.getFieldByColumnName('amount')))));
   }
   if (selectedRecords.length > 0) {
     expectedPayment.setValue(Number(totalAmountoutstanding));
@@ -747,7 +764,7 @@
 
   // Check if there is pending amount to distribute that could be distributed
   for (i = 0; i < selectedRecords.length; i++) {
-    outstandingAmount = new BigDecimal(String(orderInvoiceGrid.getRecord(i).outstandingAmount));
+    outstandingAmount = new BigDecimal(String(selectedRecords[i].outstandingAmount));
     totalOustandingAmount = totalOustandingAmount.add(outstandingAmount);
   }
   for (i = 0; i < orderInvoiceGrid.data.totalRows; i++) {
@@ -766,6 +783,11 @@
     view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('APRM_CreditWithoutBPartner'));
     return false;
   }
+  //If Actual Payment amount is negative, it is not necessary to use credit.
+  if ((total.compareTo(BigDecimal.prototype.ZERO) < 0) && (creditTotalItem.signum() !== 0)) {
+    view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('APRM_CreditWithNegativeAmt'));
+    return false;
+  }
 
   if (actualPayment.compareTo(total) > 0 && totalOustandingAmount.compareTo(amountInvOrds.add(totalWriteOffAmount)) > 0) {
     // Not all the payment amount has been allocated
--- a/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <NAME><![CDATA[JBoss Weld]]></NAME>
-<!--C70732EA90A14EC0916078B85CC33D2D-->  <VERSION><![CDATA[1.1.23921]]></VERSION>
+<!--C70732EA90A14EC0916078B85CC33D2D-->  <VERSION><![CDATA[1.1.24368]]></VERSION>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <DESCRIPTION><![CDATA[JBoss Weld]]></DESCRIPTION>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <HELP><![CDATA[Provides the JBoss Weld framework: Java Contexts and Dependency Injection for the Java EE platform (CDI). For more information see http://seamframework.org/Weld]]></HELP>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <URL><![CDATA[http://forge.openbravo.com/projects/weld]]></URL>
--- a/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <AD_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_MODULE_ID>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <DEPENDANT_MODULE_NAME><![CDATA[Core]]></DEPENDANT_MODULE_NAME>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,7 +33,7 @@
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.openbravo.base.session.OBPropertiesProvider;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * Base test for weld, provides access to the weld container.
@@ -41,7 +41,7 @@
  * @author mtaal
  */
 @RunWith(Arquillian.class)
-public class WeldBaseTest extends BaseTest {
+public class WeldBaseTest extends OBBaseTest {
 
   @Deployment
   public static JavaArchive createTestArchive() {
@@ -60,16 +60,6 @@
   @Inject
   private BeanManager beanManager;
 
-  @Before
-  public void setUp() throws Exception {
-    super.setUp();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    super.tearDown();
-  }
-
   @SuppressWarnings("unchecked")
   protected <U extends Object> U getWeldComponent(Class<U> clz) {
 
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -61,6 +61,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="ALLOWFILTERBYIDENTIFIER" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault><![CDATA['D']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_FIELD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -57,6 +57,10 @@
         <default><![CDATA[Y]]></default>
         <onCreateDefault/>
       </column>
+      <column name="ALLOWFILTERBYIDENTIFIER" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[Y]]></default>
+        <onCreateDefault><![CDATA['Y']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_SYSTEM_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -61,6 +61,10 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault/>
       </column>
+      <column name="ALLOWFILTERBYIDENTIFIER" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault><![CDATA['D']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_TAB_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PROCESS.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PROCESS.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -89,6 +89,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="ISCANADDRECORDSTOSELECTOR" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_PROC_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -101,6 +105,7 @@
       <check name="OBUIAPP_PROC_GRIDLEGACY_CHK"><![CDATA[ISGRIDLEGACY IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PROC_ISACTIVE_CHK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PROC_ISBACKGROUND_CHK"><![CDATA[ISBACKGROUND IN ('Y', 'N')]]></check>
+      <check name="OBUIAPP_PROC_ISCANADDR2SEL_CHK"><![CDATA[ISCANADDRECORDSTOSELECTOR IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PROC_MULTI_CHK"><![CDATA[ISMULTIRECORD IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PROCESS_EXPLICITACC_CK"><![CDATA[IS_EXPLICIT_ACCESS IN ('Y', 'N')]]></check>
     </table>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -1348,7 +1348,7 @@
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
-<!--26DAD0E63D554C5FA0493765032BA0B0-->  <POSITION><![CDATA[16]]></POSITION>
+<!--26DAD0E63D554C5FA0493765032BA0B0-->  <POSITION><![CDATA[14]]></POSITION>
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--26DAD0E63D554C5FA0493765032BA0B0-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -1902,7 +1902,7 @@
 <!--3E8FC3621ACE40258A020FE6B0E7A9E0-->  <DESCRIPTION><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.]]></DESCRIPTION>
 <!--3E8FC3621ACE40258A020FE6B0E7A9E0-->  <HELP><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.
 
-The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accesible in the handler from the params object. I.e:
+The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accessible in the handler from the params object. I.e:
 
 JSONArray gridRows = jsonparams.getJSONArray(ApplicationConstants.ALL_ROWS_PARAM);
 
@@ -3689,6 +3689,43 @@
 <!--7D8D82CFE40847E9ADB6B45344432038-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--7D8D82CFE40847E9ADB6B45344432038--></AD_COLUMN>
 
+<!--7E5D4C62298D4310A12AB5F28B9D2C51--><AD_COLUMN>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_COLUMN_ID><![CDATA[7E5D4C62298D4310A12AB5F28B9D2C51]]></AD_COLUMN_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <NAME><![CDATA[AllowFilterByIdentifier]]></NAME>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <COLUMNNAME><![CDATA[Allowfilterbyidentifier]]></COLUMNNAME>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_TABLE_ID><![CDATA[F167EB822B8A4284AC37D5B40B785D51]]></AD_TABLE_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_ELEMENT_ID><![CDATA[DD25DA6ACBD5424B89E09A93A5D4656C]]></AD_ELEMENT_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <POSITION><![CDATA[16]]></POSITION>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--7E5D4C62298D4310A12AB5F28B9D2C51--></AD_COLUMN>
+
 <!--7E68B314346145448A5D06B0EE98AFC9--><AD_COLUMN>
 <!--7E68B314346145448A5D06B0EE98AFC9-->  <AD_COLUMN_ID><![CDATA[7E68B314346145448A5D06B0EE98AFC9]]></AD_COLUMN_ID>
 <!--7E68B314346145448A5D06B0EE98AFC9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4295,6 +4332,43 @@
 <!--8BE595E8BE9940578AF409B85AFE02AA-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--8BE595E8BE9940578AF409B85AFE02AA--></AD_COLUMN>
 
+<!--8C5CC70F805F41B9BE4999E2A5E70C26--><AD_COLUMN>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_COLUMN_ID><![CDATA[8C5CC70F805F41B9BE4999E2A5E70C26]]></AD_COLUMN_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <NAME><![CDATA[Can Add Records to a Selector]]></NAME>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <DESCRIPTION><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window]]></DESCRIPTION>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <HELP><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window.
+This process has to be capable of adding records to a selector.]]></HELP>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <COLUMNNAME><![CDATA[IsCanAddRecordsToSelector]]></COLUMNNAME>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_TABLE_ID><![CDATA[FF80818132D7FB620132D8129D1A0028]]></AD_TABLE_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <SEQNO><![CDATA[230]]></SEQNO>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_ELEMENT_ID><![CDATA[F9B6ACA97BD34B1BBACBBC4899D9E6D8]]></AD_ELEMENT_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <POSITION><![CDATA[23]]></POSITION>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--8C5CC70F805F41B9BE4999E2A5E70C26--></AD_COLUMN>
+
 <!--8D23066BDEAB481CAAC482DD1C262218--><AD_COLUMN>
 <!--8D23066BDEAB481CAAC482DD1C262218-->  <AD_COLUMN_ID><![CDATA[8D23066BDEAB481CAAC482DD1C262218]]></AD_COLUMN_ID>
 <!--8D23066BDEAB481CAAC482DD1C262218-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -7137,7 +7211,7 @@
 <!--B85EDCE11C844C52904C24B4246BE515-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--B85EDCE11C844C52904C24B4246BE515-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--B85EDCE11C844C52904C24B4246BE515-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
-<!--B85EDCE11C844C52904C24B4246BE515-->  <POSITION><![CDATA[17]]></POSITION>
+<!--B85EDCE11C844C52904C24B4246BE515-->  <POSITION><![CDATA[15]]></POSITION>
 <!--B85EDCE11C844C52904C24B4246BE515-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--B85EDCE11C844C52904C24B4246BE515-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--B85EDCE11C844C52904C24B4246BE515-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -7650,6 +7724,43 @@
 <!--CF2A28A6B90547D8ABBCFFA026A7EFE9-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--CF2A28A6B90547D8ABBCFFA026A7EFE9--></AD_COLUMN>
 
+<!--CF562906BE6342239337F14D04D92759--><AD_COLUMN>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_COLUMN_ID><![CDATA[CF562906BE6342239337F14D04D92759]]></AD_COLUMN_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CF562906BE6342239337F14D04D92759-->  <NAME><![CDATA[AllowFilterByIdentifier]]></NAME>
+<!--CF562906BE6342239337F14D04D92759-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--CF562906BE6342239337F14D04D92759-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--CF562906BE6342239337F14D04D92759-->  <COLUMNNAME><![CDATA[Allowfilterbyidentifier]]></COLUMNNAME>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_TABLE_ID><![CDATA[8A16662B37184121A1EDAA89890E160C]]></AD_TABLE_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--CF562906BE6342239337F14D04D92759-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--CF562906BE6342239337F14D04D92759-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--CF562906BE6342239337F14D04D92759-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--CF562906BE6342239337F14D04D92759-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--CF562906BE6342239337F14D04D92759-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--CF562906BE6342239337F14D04D92759-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--CF562906BE6342239337F14D04D92759-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--CF562906BE6342239337F14D04D92759-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--CF562906BE6342239337F14D04D92759-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--CF562906BE6342239337F14D04D92759-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_ELEMENT_ID><![CDATA[DD25DA6ACBD5424B89E09A93A5D4656C]]></AD_ELEMENT_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--CF562906BE6342239337F14D04D92759-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--CF562906BE6342239337F14D04D92759-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--CF562906BE6342239337F14D04D92759-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--CF562906BE6342239337F14D04D92759-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--CF562906BE6342239337F14D04D92759-->  <POSITION><![CDATA[16]]></POSITION>
+<!--CF562906BE6342239337F14D04D92759-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--CF562906BE6342239337F14D04D92759-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--CF562906BE6342239337F14D04D92759-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--CF562906BE6342239337F14D04D92759-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--CF562906BE6342239337F14D04D92759-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--CF562906BE6342239337F14D04D92759--></AD_COLUMN>
+
 <!--D3F8F1142D914AD0ACAD03B45BEB3E9F--><AD_COLUMN>
 <!--D3F8F1142D914AD0ACAD03B45BEB3E9F-->  <AD_COLUMN_ID><![CDATA[D3F8F1142D914AD0ACAD03B45BEB3E9F]]></AD_COLUMN_ID>
 <!--D3F8F1142D914AD0ACAD03B45BEB3E9F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -8768,6 +8879,42 @@
 <!--F7DE0BA73FA64A68B898495072729D12-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--F7DE0BA73FA64A68B898495072729D12--></AD_COLUMN>
 
+<!--F900AB0A4EA649598EA364C23D6D2533--><AD_COLUMN>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_COLUMN_ID><![CDATA[F900AB0A4EA649598EA364C23D6D2533]]></AD_COLUMN_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <NAME><![CDATA[AllowFilterByIdentifier]]></NAME>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <COLUMNNAME><![CDATA[Allowfilterbyidentifier]]></COLUMNNAME>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_TABLE_ID><![CDATA[5D50320222DD4865ADFD50364C84291D]]></AD_TABLE_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <DEFAULTVALUE><![CDATA[Y]]></DEFAULTVALUE>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <SEQNO><![CDATA[150]]></SEQNO>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_ELEMENT_ID><![CDATA[DD25DA6ACBD5424B89E09A93A5D4656C]]></AD_ELEMENT_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <POSITION><![CDATA[15]]></POSITION>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--F900AB0A4EA649598EA364C23D6D2533-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--F900AB0A4EA649598EA364C23D6D2533--></AD_COLUMN>
+
 <!--FB5E84CB6C4A4EC8A812F87563B5FC4E--><AD_COLUMN>
 <!--FB5E84CB6C4A4EC8A812F87563B5FC4E-->  <AD_COLUMN_ID><![CDATA[FB5E84CB6C4A4EC8A812F87563B5FC4E]]></AD_COLUMN_ID>
 <!--FB5E84CB6C4A4EC8A812F87563B5FC4E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -67,7 +67,7 @@
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4-->  <DESCRIPTION><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.]]></DESCRIPTION>
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4-->  <HELP><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.
 
-The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accesible in the handler from the params object. I.e:
+The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accessible in the handler from the params object. I.e:
 
 JSONArray gridRows = jsonparams.getJSONArray(ApplicationConstants.ALL_ROWS_PARAM);
 
@@ -666,6 +666,20 @@
 <!--DC806316C0494E3CBE88A1F4216DB641-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--DC806316C0494E3CBE88A1F4216DB641--></AD_ELEMENT>
 
+<!--DD25DA6ACBD5424B89E09A93A5D4656C--><AD_ELEMENT>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <AD_ELEMENT_ID><![CDATA[DD25DA6ACBD5424B89E09A93A5D4656C]]></AD_ELEMENT_ID>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <COLUMNNAME><![CDATA[AllowFilterByIdentifier]]></COLUMNNAME>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <NAME><![CDATA[Allow Filtering Foreign Keys by its Identifier]]></NAME>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <PRINTNAME><![CDATA[Allow Filtering Foreign Keys by its iIdentifier]]></PRINTNAME>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--DD25DA6ACBD5424B89E09A93A5D4656C--></AD_ELEMENT>
+
 <!--E726F553F3C04DE791C8E9C1752227F9--><AD_ELEMENT>
 <!--E726F553F3C04DE791C8E9C1752227F9-->  <AD_ELEMENT_ID><![CDATA[E726F553F3C04DE791C8E9C1752227F9]]></AD_ELEMENT_ID>
 <!--E726F553F3C04DE791C8E9C1752227F9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -749,6 +763,21 @@
 <!--F39469FBB4F041BFBC730BB9E0691F29-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--F39469FBB4F041BFBC730BB9E0691F29--></AD_ELEMENT>
 
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8--><AD_ELEMENT>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <AD_ELEMENT_ID><![CDATA[F9B6ACA97BD34B1BBACBBC4899D9E6D8]]></AD_ELEMENT_ID>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <COLUMNNAME><![CDATA[IsCanAddRecordsToSelector]]></COLUMNNAME>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <NAME><![CDATA[Can Add Records to a Selector]]></NAME>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <PRINTNAME><![CDATA[Can Add Records to a Selector]]></PRINTNAME>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <DESCRIPTION><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window]]></DESCRIPTION>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <HELP><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window.
+This process has to be capable of adding records to a selector.]]></HELP>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--F9B6ACA97BD34B1BBACBBC4899D9E6D8--></AD_ELEMENT>
+
 <!--FAF5CE55DE8E4B26A9DC0610CFB30AC3--><AD_ELEMENT>
 <!--FAF5CE55DE8E4B26A9DC0610CFB30AC3-->  <AD_ELEMENT_ID><![CDATA[FAF5CE55DE8E4B26A9DC0610CFB30AC3]]></AD_ELEMENT_ID>
 <!--FAF5CE55DE8E4B26A9DC0610CFB30AC3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -63,6 +63,34 @@
 <!--031B7409581E4A5A893D04C057B93CF9-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--031B7409581E4A5A893D04C057B93CF9--></AD_FIELD>
 
+<!--03724122C8F744FDB387B47B7907E0D3--><AD_FIELD>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_FIELD_ID><![CDATA[03724122C8F744FDB387B47B7907E0D3]]></AD_FIELD_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <NAME><![CDATA[Allow Filtering Foreign Keys by its Identifier]]></NAME>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_TAB_ID><![CDATA[D26230D6D21546C6970E79FF1C51165E]]></AD_TAB_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_COLUMN_ID><![CDATA[7E5D4C62298D4310A12AB5F28B9D2C51]]></AD_COLUMN_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <SEQNO><![CDATA[120]]></SEQNO>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--03724122C8F744FDB387B47B7907E0D3--></AD_FIELD>
+
 <!--03743E0195424F98A7FB273DCB1757EF--><AD_FIELD>
 <!--03743E0195424F98A7FB273DCB1757EF-->  <AD_FIELD_ID><![CDATA[03743E0195424F98A7FB273DCB1757EF]]></AD_FIELD_ID>
 <!--03743E0195424F98A7FB273DCB1757EF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -1680,6 +1708,34 @@
 <!--4FE399927E2A4173BACE92E889B779AA-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--4FE399927E2A4173BACE92E889B779AA--></AD_FIELD>
 
+<!--50FB7470536A44D69F0EB34B18B9D1FB--><AD_FIELD>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_FIELD_ID><![CDATA[50FB7470536A44D69F0EB34B18B9D1FB]]></AD_FIELD_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <NAME><![CDATA[Allow Filtering Foreign Keys by its Identifier]]></NAME>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_TAB_ID><![CDATA[13FE911F7F684A47801DF55525BAD4A1]]></AD_TAB_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_COLUMN_ID><![CDATA[F900AB0A4EA649598EA364C23D6D2533]]></AD_COLUMN_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <SEQNO><![CDATA[100]]></SEQNO>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--50FB7470536A44D69F0EB34B18B9D1FB-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--50FB7470536A44D69F0EB34B18B9D1FB--></AD_FIELD>
+
 <!--516959378C7148DDA982C5C655796CBB--><AD_FIELD>
 <!--516959378C7148DDA982C5C655796CBB-->  <AD_FIELD_ID><![CDATA[516959378C7148DDA982C5C655796CBB]]></AD_FIELD_ID>
 <!--516959378C7148DDA982C5C655796CBB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2400,7 +2456,7 @@
 <!--784DC50B8A1845C6BFDED5F3A7DC0702-->  <DESCRIPTION><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.]]></DESCRIPTION>
 <!--784DC50B8A1845C6BFDED5F3A7DC0702-->  <HELP><![CDATA[This flags is used to specify if this process should be compatible with the legacy parameter windows.
 
-The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accesible in the handler from the params object. I.e:
+The legacy parameter windows could only contain one grid, so the _selection and _allRows properties of the grid were directly accessible in the handler from the params object. I.e:
 
 JSONArray gridRows = jsonparams.getJSONArray(ApplicationConstants.ALL_ROWS_PARAM);
 
@@ -4720,6 +4776,35 @@
 <!--F194002D518540F2AE1AB299F5B6E353-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--F194002D518540F2AE1AB299F5B6E353--></AD_FIELD>
 
+<!--F33844ACDC3A40ABAA83E614E659FC8F--><AD_FIELD>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_FIELD_ID><![CDATA[F33844ACDC3A40ABAA83E614E659FC8F]]></AD_FIELD_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <NAME><![CDATA[Can Add Records to a Selector]]></NAME>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <DESCRIPTION><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window]]></DESCRIPTION>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <HELP><![CDATA[By selecting this flag, the process will be available in the 'Defined Selector' window.
+This process has to be capable of adding records to a selector.]]></HELP>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_TAB_ID><![CDATA[FF80818132D7FB620132D819C1720046]]></AD_TAB_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_COLUMN_ID><![CDATA[8C5CC70F805F41B9BE4999E2A5E70C26]]></AD_COLUMN_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <SEQNO><![CDATA[150]]></SEQNO>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--F33844ACDC3A40ABAA83E614E659FC8F-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--F33844ACDC3A40ABAA83E614E659FC8F--></AD_FIELD>
+
 <!--F4C4E4DB9A5A4703BF738F14F96C21BA--><AD_FIELD>
 <!--F4C4E4DB9A5A4703BF738F14F96C21BA-->  <AD_FIELD_ID><![CDATA[F4C4E4DB9A5A4703BF738F14F96C21BA]]></AD_FIELD_ID>
 <!--F4C4E4DB9A5A4703BF738F14F96C21BA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4919,6 +5004,34 @@
 <!--FA25A0E775044EE180C711CC19F8E225-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--FA25A0E775044EE180C711CC19F8E225--></AD_FIELD>
 
+<!--FB4E108A4D8944D29345E465442749F2--><AD_FIELD>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_FIELD_ID><![CDATA[FB4E108A4D8944D29345E465442749F2]]></AD_FIELD_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FB4E108A4D8944D29345E465442749F2-->  <NAME><![CDATA[Allow Filtering Foreign Keys by its Identifier]]></NAME>
+<!--FB4E108A4D8944D29345E465442749F2-->  <DESCRIPTION><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually.]]></DESCRIPTION>
+<!--FB4E108A4D8944D29345E465442749F2-->  <HELP><![CDATA[If this flag is checked, then the user can filter foreign keys either by selecting some options from the filter drop down or by entering text manually. If this flag is unchecked, then the foreign keys would only be filterable by selecting some options from the filter drop down, which has better performance.]]></HELP>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_TAB_ID><![CDATA[49B33DC2EDFD45A48EECE139AD5E9AC9]]></AD_TAB_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_COLUMN_ID><![CDATA[CF562906BE6342239337F14D04D92759]]></AD_COLUMN_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--FB4E108A4D8944D29345E465442749F2-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--FB4E108A4D8944D29345E465442749F2-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--FB4E108A4D8944D29345E465442749F2-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--FB4E108A4D8944D29345E465442749F2-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FB4E108A4D8944D29345E465442749F2-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--FB4E108A4D8944D29345E465442749F2-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--FB4E108A4D8944D29345E465442749F2-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--FB4E108A4D8944D29345E465442749F2-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--FB4E108A4D8944D29345E465442749F2--></AD_FIELD>
+
 <!--FBB6C7E587984DBC9AB858EC876EC1E5--><AD_FIELD>
 <!--FBB6C7E587984DBC9AB858EC876EC1E5-->  <AD_FIELD_ID><![CDATA[FBB6C7E587984DBC9AB858EC876EC1E5]]></AD_FIELD_ID>
 <!--FBB6C7E587984DBC9AB858EC876EC1E5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -1627,6 +1627,18 @@
 <!--E4446D7FB74A4C57A9C715B4DDACC3E9-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--E4446D7FB74A4C57A9C715B4DDACC3E9--></AD_MESSAGE>
 
+<!--E645A414B1E44AF086E13259534F5FD6--><AD_MESSAGE>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <AD_MESSAGE_ID><![CDATA[E645A414B1E44AF086E13259534F5FD6]]></AD_MESSAGE_ID>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <VALUE><![CDATA[OBUIAPP_DuplicateAccess]]></VALUE>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <MSGTEXT><![CDATA[There is already a "%0" entry for role "%1"]]></MSGTEXT>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--E645A414B1E44AF086E13259534F5FD6-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--E645A414B1E44AF086E13259534F5FD6--></AD_MESSAGE>
+
 <!--E6BEA5B6AA964A57BB58B1C7BB89E8AD--><AD_MESSAGE>
 <!--E6BEA5B6AA964A57BB58B1C7BB89E8AD-->  <AD_MESSAGE_ID><![CDATA[E6BEA5B6AA964A57BB58B1C7BB89E8AD]]></AD_MESSAGE_ID>
 <!--E6BEA5B6AA964A57BB58B1C7BB89E8AD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <NAME><![CDATA[User Interface Application]]></NAME>
-<!--9BA0836A3CD74EE4AB48753A47211BCC-->  <VERSION><![CDATA[2.1.23921]]></VERSION>
+<!--9BA0836A3CD74EE4AB48753A47211BCC-->  <VERSION><![CDATA[2.1.24368]]></VERSION>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <DESCRIPTION><![CDATA[Provides the main application components for the openbravo user interface]]></DESCRIPTION>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <HELP><![CDATA[Provides the main application components for the openbravo user interface. The main layout incorporates a navigation bar and a main view area.]]></HELP>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <URL><![CDATA[http://forge.openbravo.com/projects/clientapplication]]></URL>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_DEPENDENT_MODULE_ID>
-<!--15D7CE8D95D043189162DBABA54A1F61-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--15D7CE8D95D043189162DBABA54A1F61-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON Datasource]]></DEPENDANT_MODULE_NAME>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--60A170212F36499D83B8AD38D01F46B3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <AD_DEPENDENT_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_DEPENDENT_MODULE_ID>
-<!--60A170212F36499D83B8AD38D01F46B3-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--60A170212F36499D83B8AD38D01F46B3-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Client Kernel]]></DEPENDANT_MODULE_NAME>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--824D60CB352E4099B1D8C903CA139DAE-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--824D60CB352E4099B1D8C903CA139DAE-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -49,7 +49,7 @@
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <AD_DEPENDENT_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_DEPENDENT_MODULE_ID>
-<!--E8FD820AFE3D4FE08C02FC47769026AD-->  <STARTVERSION><![CDATA[8.1.23921]]></STARTVERSION>
+<!--E8FD820AFE3D4FE08C02FC47769026AD-->  <STARTVERSION><![CDATA[8.1.24368]]></STARTVERSION>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <DEPENDANT_MODULE_NAME><![CDATA[Smartclient]]></DEPENDANT_MODULE_NAME>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REFERENCE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REFERENCE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -36,6 +36,20 @@
 <!--BCDF0DC3ECD14B07AC54287DCB1276D2-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--BCDF0DC3ECD14B07AC54287DCB1276D2--></AD_REFERENCE>
 
+<!--BF6302EFCC854FA3B75658737442CEC9--><AD_REFERENCE>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_REFERENCE_ID><![CDATA[BF6302EFCC854FA3B75658737442CEC9]]></AD_REFERENCE_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <NAME><![CDATA[Process Definition for Selector]]></NAME>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <DESCRIPTION><![CDATA[Process Definition]]></DESCRIPTION>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <HELP><![CDATA[Process Definitions that have checked the flag: "Can Add Records to a Selector"]]></HELP>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <PARENTREFERENCE_ID><![CDATA[18]]></PARENTREFERENCE_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--BF6302EFCC854FA3B75658737442CEC9--></AD_REFERENCE>
+
 <!--D6193AA7FAB6429C8F34249FBF5A5F50--><AD_REFERENCE>
 <!--D6193AA7FAB6429C8F34249FBF5A5F50-->  <AD_REFERENCE_ID><![CDATA[D6193AA7FAB6429C8F34249FBF5A5F50]]></AD_REFERENCE_ID>
 <!--D6193AA7FAB6429C8F34249FBF5A5F50-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -47,18 +47,6 @@
 <!--18ECDF9EC67E405BBEA050F45BA8D0CD-->  <SEQNO><![CDATA[40]]></SEQNO>
 <!--18ECDF9EC67E405BBEA050F45BA8D0CD--></AD_REF_LIST>
 
-<!--1B774B4E4563476DB989BF218DAA2CCF--><AD_REF_LIST>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <AD_REF_LIST_ID><![CDATA[1B774B4E4563476DB989BF218DAA2CCF]]></AD_REF_LIST_ID>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <VALUE><![CDATA[OBUIAPP_UIStartTabURL]]></VALUE>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <NAME><![CDATA[New UI start tab URL]]></NAME>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <DESCRIPTION><![CDATA[The url of the starting tab. If set then a first non-closable starting tab is created.]]></DESCRIPTION>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
-<!--1B774B4E4563476DB989BF218DAA2CCF-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
-<!--1B774B4E4563476DB989BF218DAA2CCF--></AD_REF_LIST>
-
 <!--1E1929CEE0024199A910E33A61678F60--><AD_REF_LIST>
 <!--1E1929CEE0024199A910E33A61678F60-->  <AD_REF_LIST_ID><![CDATA[1E1929CEE0024199A910E33A61678F60]]></AD_REF_LIST_ID>
 <!--1E1929CEE0024199A910E33A61678F60-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_TABLE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_TABLE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -1,5 +1,17 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--BF6302EFCC854FA3B75658737442CEC9--><AD_REF_TABLE>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_REFERENCE_ID><![CDATA[BF6302EFCC854FA3B75658737442CEC9]]></AD_REFERENCE_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_TABLE_ID><![CDATA[FF80818132D7FB620132D8129D1A0028]]></AD_TABLE_ID>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_KEY><![CDATA[0785044C8E2F41AA9F8999360F70837D]]></AD_KEY>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <AD_DISPLAY><![CDATA[6B89B4DC342B48F989E55D70BB2CC9B0]]></AD_DISPLAY>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--BF6302EFCC854FA3B75658737442CEC9-->  <WHERECLAUSE><![CDATA[OBUIAPP_Process.ISCANADDRECORDSTOSELECTOR='Y']]></WHERECLAUSE>
+<!--BF6302EFCC854FA3B75658737442CEC9--></AD_REF_TABLE>
+
 <!--D6193AA7FAB6429C8F34249FBF5A5F50--><AD_REF_TABLE>
 <!--D6193AA7FAB6429C8F34249FBF5A5F50-->  <AD_REFERENCE_ID><![CDATA[D6193AA7FAB6429C8F34249FBF5A5F50]]></AD_REFERENCE_ID>
 <!--D6193AA7FAB6429C8F34249FBF5A5F50-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/DynamicExpressionParserTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/DynamicExpressionParserTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,20 +11,22 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
  */
 package org.openbravo.client.application.test;
 
+import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 import org.openbravo.client.application.DynamicExpressionParser;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.ui.Tab;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class DynamicExpressionParserTest extends BaseTest {
+public class DynamicExpressionParserTest extends OBBaseTest {
 
   @Test
   public void testRegularExpression() {
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTemplateTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTemplateTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,13 +11,15 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
  */
 package org.openbravo.client.application.test;
 
+import static org.junit.Assert.assertTrue;
+
 import javax.inject.Inject;
 
 import org.junit.Test;
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,13 +11,15 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
  */
 package org.openbravo.client.application.test;
 
+import static org.junit.Assert.assertFalse;
+
 import javax.inject.Inject;
 
 import org.junit.Test;
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/StandardWindowTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/StandardWindowTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -18,6 +18,7 @@
  */
 package org.openbravo.client.application.test;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.openbravo.base.weld.test.WeldBaseTest;
 import org.openbravo.client.application.window.StandardWindowComponent;
@@ -55,6 +56,8 @@
   /**
    * Tests generating the javascript for one window to analyze problems.
    */
+  @Ignore
+  @Test
   public void _testOneStandardViewGeneration() throws Exception {
     setSystemAdministratorContext();
     generateForWindow(OBDal.getInstance().get(Window.class, "1005400002"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RoleAccessUniqueHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -0,0 +1,125 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU 
+ * All portions are Copyright (C) 2014 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.client.application.event;
+
+import javax.enterprise.event.Observes;
+
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.base.model.Property;
+import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.client.application.ProcessAccess;
+import org.openbravo.client.application.ViewRoleAccess;
+import org.openbravo.client.kernel.event.EntityNewEvent;
+import org.openbravo.client.kernel.event.EntityPersistenceEvent;
+import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
+import org.openbravo.client.kernel.event.EntityUpdateEvent;
+import org.openbravo.client.myob.WidgetClassAccess;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.ad.access.Role;
+
+/**
+ * Ensures there are no duplicates entries in access tabs for Widgets, Process Definitions and View
+ * Implementations.
+ * 
+ * Implemented as <code>EntityPersistenceEventObserver</code> instead of DB constraint to maintain
+ * backwards compatibility. See issue https://issues.openbravo.com/view.php?id=27074
+ * 
+ * @author alostale
+ *
+ */
+public class RoleAccessUniqueHandler extends EntityPersistenceEventObserver {
+  private static final String WIDGET_CLASS_ACCESS_TABLE_ID = "D1829E5F3A8441BF85DDBC06D49C1074";
+  private static final String PROCESS_DEF_ACCESS_TABLE_ID = "FF80818132D85DB50132D860924E0004";
+  private static final String VIEW_ACCESS_TALBLE_ID = "E6F29F8A30BC4603B1D1195051C4F3A6";
+
+  private static final Entity WIDGET_CLASS_ACCESS_ENTITY = ModelProvider.getInstance()
+      .getEntityByTableId(WIDGET_CLASS_ACCESS_TABLE_ID);
+  private static final Entity PROCESS_DEF_ACCESS_ENTITY = ModelProvider.getInstance()
+      .getEntityByTableId(PROCESS_DEF_ACCESS_TABLE_ID);
+  private static final Entity VIEW_ACCESS_ENTITY = ModelProvider.getInstance().getEntityByTableId(
+      VIEW_ACCESS_TALBLE_ID);
+
+  private static final Entity[] entities = { WIDGET_CLASS_ACCESS_ENTITY, PROCESS_DEF_ACCESS_ENTITY,
+      VIEW_ACCESS_ENTITY };
+
+  public void onInsert(@Observes EntityNewEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+
+    checkUniqueness(event);
+  }
+
+  public void onUpdate(@Observes EntityUpdateEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    checkUniqueness(event);
+  }
+
+  private void checkUniqueness(EntityPersistenceEvent event) {
+    Entity entity = event.getTargetInstance().getEntity();
+
+    Role newRole = (Role) event.getCurrentState(entity.getProperty("role"));
+
+    // securedObjectProperty is the property (different based on the observed entity) that links to
+    // the secured object. This property together with role must be unique
+    Property securedObjectProperty;
+    if (entity.equals(WIDGET_CLASS_ACCESS_ENTITY)) {
+      securedObjectProperty = WIDGET_CLASS_ACCESS_ENTITY
+          .getProperty(WidgetClassAccess.PROPERTY_WIDGETCLASS);
+    } else if (entity.equals(PROCESS_DEF_ACCESS_ENTITY)) {
+      securedObjectProperty = PROCESS_DEF_ACCESS_ENTITY
+          .getProperty(ProcessAccess.PROPERTY_OBUIAPPPROCESS);
+    } else {
+      securedObjectProperty = VIEW_ACCESS_ENTITY
+          .getProperty(ViewRoleAccess.PROPERTY_VIEWIMPLEMENTATION);
+    }
+
+    OBCriteria<BaseOBObject> q = OBDal.getInstance().createCriteria(entity.getName());
+
+    q.add(Restrictions.eq("role", newRole));
+    q.add(Restrictions.eq(securedObjectProperty.getName(),
+        event.getCurrentState(securedObjectProperty)));
+
+    if (event instanceof EntityUpdateEvent) {
+      // do not count itself when updating
+      q.add(Restrictions.ne("id", event.getId()));
+    }
+
+    if (q.count() > 0) {
+      throw new OBException(OBMessageUtils.getI18NMessage(
+          "OBUIAPP_DuplicateAccess",
+          new String[] {
+              ((BaseOBObject) event.getCurrentState(securedObjectProperty)).getIdentifier(),
+              newRole.getName() }));
+    }
+  }
+
+  @Override
+  protected Entity[] getObservedEntities() {
+    return entities;
+  }
+}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -22,7 +22,9 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.util.Check;
@@ -77,11 +79,19 @@
         return jsonRequest;
       }
 
+      JSONObject context = null;
+      if (StringUtils.isNotEmpty(content)) {
+        try {
+          context = new JSONObject(content);
+        } catch (JSONException e) {
+          log.error("Error getting context for process definition " + processDefinition, e);
+        }
+      }
       for (Parameter param : processDefinition.getOBUIAPPParameterList()) {
         if (param.isFixed()) {
           if (param.isEvaluateFixedValue()) {
             parameters.put(param.getDBColumnName(),
-                ParameterUtils.getParameterFixedValue(fixRequestMap(parameters), param));
+                ParameterUtils.getParameterFixedValue(fixRequestMap(parameters, context), param));
           } else {
             parameters.put(param.getDBColumnName(), param.getFixedValue());
           }
@@ -200,11 +210,21 @@
     return qAccess.count() > 0;
   }
 
-  /*
+  /**
    * The request map is <String, Object> because includes the HTTP request and HTTP session, is not
    * required to handle process parameters
+   * 
+   * @deprecated use {@link BaseProcessActionHandler#fixRequestMap(Map, JSONObject)}
    */
   protected Map<String, String> fixRequestMap(Map<String, Object> parameters) {
+    return fixRequestMap(parameters, null);
+  }
+
+  /**
+   * Fixes the request map adding an "context" key to include context info in order to make it
+   * available to be evaluated by FilterExpression
+   */
+  protected Map<String, String> fixRequestMap(Map<String, Object> parameters, JSONObject context) {
     final Map<String, String> retval = new HashMap<String, String>();
     for (Entry<String, Object> entries : parameters.entrySet()) {
       if (entries.getKey().equals(KernelConstants.HTTP_REQUEST)
@@ -213,6 +233,9 @@
       }
       retval.put(entries.getKey(), entries.getValue().toString());
     }
+    if (context != null) {
+      retval.put("context", context.toString());
+    }
     return retval;
   }
 
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/DefaultsProcessActionHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/DefaultsProcessActionHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -24,6 +24,7 @@
 
 import javax.servlet.http.HttpSession;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -67,12 +68,17 @@
       OBContext.setAdminMode(true);
 
       final String processId = (String) parameters.get("processId");
+      final Process processDefinition = OBDal.getInstance().get(Process.class, processId);
 
       JSONObject context = null;
-      if (parameters.get("context") != null) {
-        context = new JSONObject((String) parameters.get("context"));
+      if (StringUtils.isNotEmpty(content)) {
+        try {
+          context = new JSONObject(content);
+        } catch (JSONException e) {
+          log.error("Error getting context for process definition " + processDefinition, e);
+        }
       }
-      final Process processDefinition = OBDal.getInstance().get(Process.class, processId);
+
       JSONObject defaults = new JSONObject();
       JSONObject filterExpressions = new JSONObject();
       final List<Parameter> orderedParams = new ArrayList<Parameter>();
@@ -105,7 +111,7 @@
               defaultValue = context.get(inpName);
               inpName = "inp" + Sqlc.TransformaNombreColumna(param.getDBColumnName());
             } else {
-              Map<String, String> requestMap = fixRequestMap(parameters);
+              Map<String, String> requestMap = fixRequestMap(parameters, context);
               requestMap.put("currentParam", param.getDBColumnName());
               defaultValue = ParameterUtils.getJSExpressionResult(requestMap,
                   (HttpSession) parameters.get(KernelConstants.HTTP_SESSION), rawDefaultValue);
@@ -156,7 +162,7 @@
                   Object defaultExpression;
                   parameters.put("filterExpressionColumnName", field.getColumn().getDBColumnName());
                   defaultExpression = ParameterUtils.getJSExpressionResult(
-                      fixRequestMap(parameters),
+                      fixRequestMap(parameters, context),
                       (HttpSession) parameters.get(KernelConstants.HTTP_SESSION),
                       rawDefaultExpression);
 
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed Sep 03 16:32:14 2014 +0200
@@ -177,7 +177,9 @@
       List<String> overwrittenAuxiliaryInputs = new ArrayList<String>();
       // The provided overwrittenAuxiliaryInputs only have to be persisted when calling the FIC in
       // CHANGE mode. In the rest of the modes all auxiliary inputs are computed regardless of
-      // whether a callout have modified them in a previous request
+      // whether a callout have modified them in a previous request with the exception of NEW. In
+      // NEW mode auxiliary inputs are not recomputed if they were previously calculated by callouts
+      // (within in the same request)
       if (jsContent.has("overwrittenAuxiliaryInputs") && "CHANGE".equals(mode)) {
         overwrittenAuxiliaryInputs = convertJSONArray(jsContent
             .getJSONArray("overwrittenAuxiliaryInputs"));
@@ -547,6 +549,11 @@
     String attribute = null, attrValue = null;
     for (String attrName : parser.getSessionAttributes()) {
       if (!sessionAttributesMap.containsKey(attrName)) {
+        if (attrName.startsWith("inp_propertyField")) {
+          // do not add the property fields to the session attributes to avoid overwriting its value
+          // with an empty string
+          continue;
+        }
         if (attrName.startsWith("#")) {
           attribute = attrName.substring(1, attrName.length());
           attrValue = Utility.getContext(new DalConnectionProvider(false), RequestContext.get()
@@ -888,7 +895,7 @@
   private void computeAuxiliaryInputs(String mode, Tab tab, Map<String, JSONObject> columnValues,
       List<String> overwrittenAuxiliaryInputs) {
     for (AuxiliaryInput auxIn : getAuxiliaryInputList(tab.getId())) {
-      if (mode.equals("CHANGE")) {
+      if (mode.equals("CHANGE") || mode.equals("NEW")) {
         // Don't compute the auxiliary inputs that have been overwritten by callouts
         if (overwrittenAuxiliaryInputs.contains(auxIn.getName())) {
           continue;
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -1323,7 +1323,7 @@
       getUIDefinition().establishGridConfigurationSettings(field);
 
       if (getClientClass().length() > 0) {
-        return "editorType: 'OBClientClassCanvasItem', filterEditorType: 'TextItem', ";
+        return "editorType: 'OBClientClassCanvasItem', ";
       }
 
       String jsonString = getUIDefinition().getFieldProperties(field).trim();
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewParameterHandler.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewParameterHandler.java	Wed Sep 03 16:32:14 2014 +0200
@@ -238,7 +238,8 @@
     }
 
     public boolean isRequired() {
-      return parameter.isMandatory();
+      // grid params should always be marked as not mandatory
+      return !isGrid() && parameter.isMandatory();
     }
 
     public boolean isGrid() {
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Wed Sep 03 16:32:14 2014 +0200
@@ -23,6 +23,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
@@ -65,6 +66,7 @@
 import org.openbravo.service.datasource.DataSourceConstants;
 import org.openbravo.service.db.DalConnectionProvider;
 import org.openbravo.service.json.JsonConstants;
+import org.openbravo.userinterface.selector.Selector;
 import org.openbravo.utils.FormatUtilities;
 
 /**
@@ -560,16 +562,43 @@
 
   public String getProcessViews() {
     StringBuilder views = new StringBuilder();
+    // Use HashSet to avoid processId duplicities
+    HashSet<String> processIds = new HashSet<String>();
     for (ButtonField f : getButtonFields()) {
+      // Get processes coming from action buttons
       if (f.column.getOBUIAPPProcess() == null
           || !"OBUIAPP_PickAndExecute".equals(f.column.getOBUIAPPProcess().getUIPattern())) {
         continue;
       }
+      processIds.add(f.column.getOBUIAPPProcess().getId());
+    }
+    final List<Field> adFields = new ArrayList<Field>(tab.getADFieldList());
+    Collections.sort(adFields, new FormFieldComparator());
+    for (Field fld : adFields) {
+      // Get processes coming from selectors
+      if (fld.isActive() && fld.isDisplayed()) {
+        if (fld.getColumn() == null || fld.getColumn().getReferenceSearchKey() == null) {
+          continue;
+        }
+        List<Selector> selectors = fld.getColumn().getReferenceSearchKey().getOBUISELSelectorList();
+        if (selectors.size() == 0) {
+          continue;
+        }
+        Selector selector = selectors.get(0);
 
+        if (selector.getProcessDefintion() == null) {
+          continue;
+        }
+        processIds.add(selector.getProcessDefintion().getId());
+      }
+    }
+    for (String processId : processIds) {
+      org.openbravo.client.application.Process process = OBDal.getInstance().get(
+          org.openbravo.client.application.Process.class, processId);
       final ParameterWindowComponent processWindow = createComponent(ParameterWindowComponent.class);
       processWindow.setParameters(getParameters());
       processWindow.setUniqueString(uniqueString);
-      processWindow.setProcess(f.column.getOBUIAPPProcess());
+      processWindow.setProcess(process);
       processWindow.setParentWindow(getTab().getWindow());
       processWindow.setPoup(true);
       // processWindow.setWindow(OBDal.getInstance().get(Window.class, f.getWindowId()));
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Wed Sep 03 16:32:14 2014 +0200
@@ -176,13 +176,14 @@
     Boolean canFilter = null;
     Boolean filterOnChange = null;
     Boolean lazyFiltering = null;
+    Boolean allowFkFilterByIdentifier = null;
     String operator = null;
     Long thresholdToFilter = null;
     JSONObject result = new JSONObject();
 
     if (field != null && field.getId() != null) {
       if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-          || thresholdToFilter == null) {
+          || thresholdToFilter == null || allowFkFilterByIdentifier == null) {
         List<Object> fieldParams = new ArrayList<Object>();
         String fieldConfsHql = " as p where p.field.id = ? ";
         fieldParams.add(field.getId());
@@ -217,6 +218,13 @@
               filterOnChange = false;
             }
           }
+          if (allowFkFilterByIdentifier == null) {
+            if ("Y".equals(fieldConfs.get(0).getAllowFilterByIdentifier())) {
+              allowFkFilterByIdentifier = true;
+            } else if ("N".equals(fieldConfs.get(0).getAllowFilterByIdentifier())) {
+              allowFkFilterByIdentifier = false;
+            }
+          }
           if (thresholdToFilter == null) {
             thresholdToFilter = fieldConfs.get(0).getThresholdToFilter();
           }
@@ -225,7 +233,7 @@
     }
 
     if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-        || thresholdToFilter == null) {
+        || thresholdToFilter == null || allowFkFilterByIdentifier == null) {
       List<Object> tabParams = new ArrayList<Object>();
       String tabConfsHql = " as p where p.tab.id = ? ";
       tabParams.add(tab.getId());
@@ -267,6 +275,14 @@
             lazyFiltering = false;
           }
         }
+        if (allowFkFilterByIdentifier == null) {
+          if ("Y".equals(tabConfs.get(0).getAllowFilterByIdentifier())) {
+            allowFkFilterByIdentifier = true;
+          } else if ("N".equals(tabConfs.get(0).getAllowFilterByIdentifier())) {
+            allowFkFilterByIdentifier = false;
+          }
+        }
+
         if (thresholdToFilter == null) {
           thresholdToFilter = tabConfs.get(0).getThresholdToFilter();
         }
@@ -296,6 +312,9 @@
         if (thresholdToFilter == null) {
           thresholdToFilter = sysConfs.get(0).getThresholdToFilter();
         }
+        if (allowFkFilterByIdentifier == null) {
+          allowFkFilterByIdentifier = sysConfs.get(0).isAllowFilterByIdentifier();
+        }
       }
     }
 
@@ -335,6 +354,9 @@
       if (thresholdToFilter != null) {
         result.put("thresholdToFilter", thresholdToFilter);
       }
+      if (allowFkFilterByIdentifier != null) {
+        result.put("allowFkFilterByIdentifier", allowFkFilterByIdentifier);
+      }
     } catch (JSONException e) {
       log.error("Couldn't get field property value");
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-window.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-window.js	Wed Sep 03 16:32:14 2014 +0200
@@ -354,7 +354,9 @@
       while (parentFrame.name !== '') {
         parentFrame = parentFrame.parent;
       }
-      parentFrame.activeFrame = iFrame;
+      if (parentFrame.parent) {
+        parentFrame.parent.activeFrame = iFrame;
+      }
     }
   }
 });
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-canvas.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-canvas.js	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2013 Openbravo SLU
+ * All portions are Copyright (C) 2011-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -147,4 +147,63 @@
       this.grid.body.markForRedraw();
     }
   }
+});
+
+isc.defineClass('OBLevelImg', isc.Img);
+
+isc.OBLevelImg.addProperties({
+  cellAlign: 'center',
+  canEdit: false,
+  isShownInGridEdit: true,
+  // The valueList should be overridden if this canvas item is applied to a different scale, for example ['none', 'weak', 'small', 'medium', 'high']
+  valuesList: [0, 1, 2, 3, 4],
+
+  setState: function () {
+    //To avoid add "_Disabled" to the src image if the grid row is disabled
+    return '';
+  },
+
+  click: function () {
+    if (this.grid) {
+      this.grid.selectSingleRecord(this.record);
+    }
+    return this.Super('click', arguments);
+  },
+
+  setValue: function (value) {
+    var i;
+    if (!value) {
+      if (this.value) {
+        value = this.value;
+      } else {
+        return;
+      }
+    }
+    for (i = 0; i < this.valuesList.length; i++) {
+      if (value.toString() === this.valuesList[i].toString()) {
+        value = i;
+      }
+    }
+    if (typeof value === 'number' && value >= 0 && value < this.valuesList.length) {
+      this.value = value;
+      this.setWidth(41);
+      this.setHeight(20);
+      this.setSrc(OB.Styles.skinsPath + 'Default/org.openbravo.client.application/images/form/levelImg_' + value.toString() + '_' + (this.valuesList.length - 1).toString() + '.png');
+    } else {
+      this.value = null;
+      this.setWidth(1);
+      this.setHeight(1);
+      this.setSrc(OB.Styles.skinsPath + 'Default/smartclient/images/blank.gif');
+    }
+  },
+
+  showValue: function (displayValue, dataValue, form, item) {
+    this.setValue(dataValue);
+  },
+
+  setRecord: function (record) {
+    if (this.field && this.field.name && record[this.field.name]) {
+      this.setValue(record[this.field.name]);
+    }
+  }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed Sep 03 16:32:14 2014 +0200
@@ -42,6 +42,11 @@
   changeOnKeypress: true,
   addUnknownValues: true,
   defaultToFirstOption: false,
+  // filterType = {'id', 'identifier'}
+  // filterType = 'id' means that the foreign key will be filtered using the record ids. This is only possible when filtering the grid by selecting a record from the filter drop down
+  // filterType = 'identifier' means that the foreign key will be filtered using the record ids
+  filterType: 'identifier',
+  filterAuxCache: [],
 
   emptyPickListMessage: OB.I18N.getLabel('OBUISC_ListGrid.emptyMessage'),
 
@@ -72,9 +77,10 @@
         if (gridView) {
           requestProperties.params.tabId = gridView.tabId || (gridView.sourceView && gridView.sourceView.tabId);
         }
-        //send the display field in request params to add it to the list of fields to be fetched.
-        if (this.formItem && this.formItem.displayField) {
-          requestProperties.params.displayField = this.formItem.displayField;
+        // send the display field in request params to add it to the list of fields to be fetched in DefaultJsonDataService.
+        // used for displaying table references properly. Refer issue https://issues.openbravo.com/view.php?id=26696
+        if (this.formItem && this.formItem.displayProperty) {
+          requestProperties.params.displayProperty = this.formItem.displayProperty;
         }
         delete me.forceReload;
       },
@@ -150,6 +156,11 @@
     this.observe(grid, "dataArrived", "observer.setForceReload()");
 
     this.multipleValueSeparator = ' or ';
+
+    // if the filter by identifier has been disabled using grid configuration, set the filter type to 'id'
+    if (this.allowFkFilterByIdentifier === false) {
+      this.filterType = 'id';
+    }
   },
 
   destroy: function () {
@@ -199,13 +210,42 @@
   },
 
   blur: function () {
-    if (this._hasChanged) {
+    if (this._hasChanged && this.allowFkFilterByIdentifier === false) {
+      // close the picklist if the item is due to a user tab action
+      if (isc.EH.getKeyName() === 'Tab') {
+        this.pickList.hide();
+      }
+      // restore the filter editor with the previous criteria
+      this.setCriterion(this.getAppliedCriteria());
+      // do not perform a filter action on blur if the filtering by identifier is not allowed
+    } else if (this._hasChanged && this.allowFkFilterByIdentifier !== false) {
       this.form.grid.performAction();
     }
     delete this._hasChanged;
     this.Super('blur', arguments);
   },
 
+  // returns the criteria for this field that is applied to the data that the grid is currently showing
+  // this.getCriteria() would return the modified criteria that needs to be reverted
+  getAppliedCriteria: function () {
+    var currentGridCriteria = this.grid.sourceWidget.getCriteria(),
+        i, emptyCriteria = {
+        operator: "and",
+        _constructor: "AdvancedCriteria",
+        criteria: []
+        };
+    if (!currentGridCriteria || !currentGridCriteria.criteria) {
+      return emptyCriteria;
+    }
+    for (i = 0; i < currentGridCriteria.criteria.length; i++) {
+      if (currentGridCriteria.criteria[i].fieldName === this.name) {
+        return currentGridCriteria.criteria[i];
+      }
+    }
+    // if no criteria was found for this field, return an empty criteria
+    return emptyCriteria;
+  },
+
   // overridden otherwise the picklist fields from the grid field
   // are being used
   getPickListFields: function () {
@@ -243,7 +283,8 @@
   // combine the value of the field with the overall grid
   // filter values
   getPickListFilterCriteria: function () {
-    var pickListCriteria = this.getCriterion(),
+    var forceFilterByIdentifier = true,
+        pickListCriteria = this.getCriterion(null, forceFilterByIdentifier),
         gridCriteria, i, criteriaFieldName = this.getCriteriaFieldName();
 
     if (this.form.grid.sourceWidget.lazyFiltering) {
@@ -308,10 +349,15 @@
     }
   },
 
-  getCriterion: function (textMatchStyle) {
-    var value = this.getCriteriaValue(),
-        operator, fieldName, crit;
+  getCriterion: function (textMatchStyle, forceFilterByIdentifier) {
+    var value, operator, fieldName, crit;
 
+    // sometimes (i.e. when the filter drop down is populated) it is needed to force a filter using the identifier
+    // if the filter using the identifier is not allowed, the filter type will be reverted to 'id' at the end of this function
+    if (forceFilterByIdentifier) {
+      this.filterType = 'identifier';
+    }
+    value = this.getCriteriaValue();
     if (value === null || isc.is.emptyString(value)) {
       return;
     }
@@ -339,14 +385,22 @@
       crit = this.replaceCriterionOperator(crit, value, this.operator);
     }
 
+    if (this.allowFkFilterByIdentifier === false) {
+      this.filterType = 'id';
+    }
+
     return crit;
   },
 
   getOperator: function (textMatchStyle) {
-    if (this.operator && this.operator !== 'iContains') {
-      return this.operator;
+    if (this.filterType === 'id') {
+      return 'equals';
     } else {
-      return this.Super('getOperator', arguments);
+      if (this.operator && this.operator !== 'iContains') {
+        return this.operator;
+      } else {
+        return this.Super('getOperator', arguments);
+      }
     }
   },
 
@@ -370,15 +424,21 @@
 
   setCriterion: function (criterion) {
     var i, value, values = [],
-        operators, valueSet = false,
-        criteria = criterion ? criterion.criteria : null;
+        operators = isc.DataSource.getSearchOperators(),
+        valueSet = false,
+        criteria = criterion ? criterion.criteria : null,
+        identifier;
     if (criteria && criteria.length && criterion.operator === 'or') {
-      operators = isc.DataSource.getSearchOperators();
       for (i = 0; i < criteria.length; i++) {
         //handles case where column filter symbols are removed. Refer Issue https://issues.openbravo.com/view.php?id=23925
         if (criteria[i].operator !== "iContains" && criteria[i].operator !== "contains" && criteria[i].operator !== "regexp") {
-          if (operators[criteria[i].operator] && (operators[criteria[i].operator].ID === criteria[i].operator) && operators[criteria[i].operator].symbol && criteria[i].value && (criteria[i].value.indexOf(operators[criteria[i].operator].symbol) === -1)) {
-            values.push(operators[criteria[i].operator].symbol + criteria[i].value);
+          value = criteria[i].value;
+          if (operators[criteria[i].operator] && (operators[criteria[i].operator].ID === criteria[i].operator) && operators[criteria[i].operator].symbol && value && (value.indexOf(operators[criteria[i].operator].symbol) === -1)) {
+            identifier = this.getRecordIdentifierFromId(value);
+            if (this.filterType === 'id' && identifier) {
+              value = identifier;
+            }
+            values.push(operators[criteria[i].operator].symbol + value);
             valueSet = true;
           }
         }
@@ -390,6 +450,17 @@
       this.setValue(values);
     } else {
       value = this.buildValueExpressions(criterion);
+      if (this.filterType === 'id') {
+        identifier = this.getRecordIdentifierFromId(value);
+        if (identifier) {
+          value = identifier;
+        }
+      }
+      if (criterion.operator !== "iContains" && criterion.operator !== "contains" && criterion.operator !== "regexp") {
+        if (operators[criterion.operator] && (operators[criterion.operator].ID === criterion.operator) && operators[criterion.operator].symbol && value && (value.indexOf(operators[criterion.operator].symbol) === -1)) {
+          value = operators[criterion.operator].symbol + value;
+        }
+      }
       this.setValue(value);
     }
     // if iBetweenInclusive operator is used, delete the ZZZZZZZZZZ
@@ -404,7 +475,11 @@
   // see also the setValuesAsCriteria in ob-grid-js which again translates
   // back
   getCriteriaFieldName: function () {
-    return this.criteriaField || this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER;
+    if (this.filterType === 'id') {
+      return this.name;
+    } else {
+      return this.criteriaField || this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER;
+    }
   },
 
   // solve a small bug in the value expressions
@@ -460,5 +535,70 @@
       }
     }
     return false;
+  },
+
+  pickValue: function (value) {
+    // this is needed to discern if the text has been changed automatically when a record is selected, or manually by the user
+    this._pickingValue = true;
+    this.Super('pickValue', arguments);
+    delete this._pickingValue;
+  },
+
+  handleChanged: function (value) {
+    if (this._pickingValue || this.allowFkFilterByIdentifier === false) {
+      // if the filter text has changed because a value has been ficked from the filter drop down, use the id filter
+      // do this also if the only filter type allowed is 'id'
+      this.filterType = 'id';
+    } else {
+      // otherwise use the standard filter using the record identifier
+      this.filterType = 'identifier';
+    }
+    this.Super('handleChanged', arguments);
+  },
+
+  // if the filterType is ID, try to return the record ids instead of the record identifiers
+  getCriteriaValue: function () {
+    var value, values = this.getValue(),
+        record, i, criteriaValues = [],
+        recordId;
+    if (values && this.filterType === 'id') {
+      for (i = 0; i < values.length; i++) {
+        value = values[i];
+        if (value.startsWith('==')) {
+          // if the value has the equals operator prefix, get rid of it
+          value = value.substring(2);
+        }
+        recordId = this.getRecordIdFromIdentifier(value);
+        if (!recordId) {
+          // if the record is not found  or it does not have an id, use the standard criteria value
+          return this.Super('getCriteriaValue', arguments);
+        } else {
+          criteriaValues.add(recordId);
+        }
+      }
+      return criteriaValues;
+    } else {
+      return this.Super('getCriteriaValue', arguments);
+    }
+  },
+
+  getRecordIdFromIdentifier: function (identifier) {
+    var recordId;
+    if (this.pickList && this.pickList.data.find(OB.Constants.IDENTIFIER, identifier)) {
+      recordId = this.pickList.data.find(OB.Constants.IDENTIFIER, identifier)[OB.Constants.ID];
+    } else if (this.filterAuxCache && this.filterAuxCache.find(OB.Constants.IDENTIFIER, identifier)) {
+      recordId = this.filterAuxCache.find(OB.Constants.IDENTIFIER, identifier)[OB.Constants.ID];
+    }
+    return recordId;
+  },
+
+  getRecordIdentifierFromId: function (id) {
+    var recordIdentifier;
+    if (this.pickList && this.pickList.data.find(OB.Constants.ID, id)) {
+      recordIdentifier = this.pickList.data.find(OB.Constants.ID, id)[OB.Constants.IDENTIFIER];
+    } else if (this.filterAuxCache && this.filterAuxCache.find(OB.Constants.ID, id)) {
+      recordIdentifier = this.filterAuxCache.find(OB.Constants.ID, id)[OB.Constants.IDENTIFIER];
+    }
+    return recordIdentifier;
   }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js	Wed Sep 03 16:32:14 2014 +0200
@@ -286,6 +286,12 @@
       dsRequest.params._startRow = 0;
       dsRequest.params._endRow = OB.Properties.TreeDatasourceFetchLimit;
       dsRequest.params.treeReferenceId = target.treeItem.treeReferenceId;
+      var contextInfo = target.treeItem.form.view.getContextInfo(false, true);
+      isc.addProperties(dsRequest.params, contextInfo);
+      // if the tree item has defined manually a function to add params to the request, do it
+      if (target.treeItem.addParamsToRequest) {
+        isc.addProperties(dsRequest.params, target.treeItem.addParamsToRequest());
+      }
       return this.Super('transformRequest', arguments);
     };
 
@@ -516,11 +522,14 @@
       setDataSource: function (ds, fields) {
         var me = this;
         ds.transformRequest = function (dsRequest) {
-          var target = window[dsRequest.componentId];
+          var target = window[dsRequest.componentId],
+              contextInfo;
           dsRequest.params = dsRequest.params || {};
           dsRequest.params._startRow = 0;
           dsRequest.params._endRow = OB.Properties.TreeDatasourceFetchLimit;
           dsRequest.params.treeReferenceId = target.treeItem.treeReferenceId;
+          contextInfo = target.treeItem.form.view.getContextInfo(false, true);
+          isc.addProperties(dsRequest.params, contextInfo);
           return this.Super('transformRequest', arguments);
         };
 
@@ -674,11 +683,12 @@
 isc.OBTreeFilterSelectItem.addProperties({
 
   filterDataBoundPickList: function (requestProperties, dropCache) {
+    var contextInfo;
     requestProperties = requestProperties || {};
     requestProperties.params = requestProperties.params || {};
     // on purpose not passing the third boolean param
-    var contextInfo = this.treeWindow.treeItem.form.view.getContextInfo(false, true);
-
+    contextInfo = this.treeWindow.treeItem.form.view.getContextInfo(false, true);
+    isc.addProperties(requestProperties.params, contextInfo);
     // also add the special ORG parameter
     if (this.treeWindow.treeItem.form.getField('organization')) {
       requestProperties.params[OB.Constants.ORG_PARAMETER] = this.treeWindow.treeItem.form.getValue('organization');
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Sep 03 16:32:14 2014 +0200
@@ -266,7 +266,11 @@
   },
 
   editNewRecord: function (preventFocus) {
+    var grid = this.view.viewGrid;
     this.clearValues();
+    if (grid.lazyFiltering && !isc.isA.ResultSet(grid.data)) {
+      OB.Utilities.createResultSetManually(grid);
+    }
     var ret = this.Super('editNewRecord', arguments);
     this.doEditRecordActions(preventFocus, true);
     return ret;
@@ -1032,7 +1036,7 @@
       isDate = field.type && (typeInstance.inheritsFrom === 'date' || typeInstance.inheritsFrom === 'time');
       isDateTime = field.type && typeInstance.inheritsFrom === 'datetime';
       isImage = field.type && typeInstance.inheritsFrom === 'image';
-      if (isDateTime && typeInstance.editorType && new Function('return isc.' + typeInstance.editorType + '.getPrototype().isAbsoluteDateTime')()) {
+      if (isDateTime && typeInstance.editorType && OB.Utilities.getCanvasProp(typeInstance.editorType, 'isAbsoluteDateTime')) {
         isAbsoluteDateTime = true;
         isDateTime = false;
       }
@@ -1566,7 +1570,9 @@
       // if no recordIndex then select explicitly
       if (recordIndex === -1) {
         record = view.viewGrid.data.find('id', id);
-        recordIndex = view.viewGrid.data.indexOf(record);
+        if (record !== null) {
+          recordIndex = view.viewGrid.data.indexOf(record);
+        }
       }
 
       // not in the filter, insert the record in the cachedata so it will be made visible
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Sep 03 16:32:14 2014 +0200
@@ -22,7 +22,7 @@
 // The OBGrid combines common grid functionality usefull for different 
 // grid implementations.
 isc.OBGrid.addProperties({
-
+  bodyConstructor: 'OBViewGridBody',
   reverseRTLAlign: true,
   dragTrackerMode: 'none',
   // recycle gives better performance but also results
@@ -77,6 +77,18 @@
     return value;
   },
 
+  onFetchData: function (criteria, requestProperties) {
+    this.setFechingData();
+  },
+
+  setFechingData: function () {
+    this.fetchingData = true;
+  },
+
+  isFetchingData: function () {
+    return this.fetchingData;
+  },
+
   cellHoverHTML: function (record, rowNum, colNum) {
 
     var ret, field = this.getField(colNum),
@@ -239,6 +251,15 @@
     return false;
   },
 
+  getCellAlign: function (record, rowNum, colNum) {
+    var fld = this.getFields()[colNum];
+    if (fld && fld.clientClass && OB.Utilities.getCanvasProp(fld.clientClass, 'cellAlign')) {
+      return OB.Utilities.getCanvasProp(fld.clientClass, 'cellAlign');
+    } else {
+      return this.Super('getCellAlign', arguments);
+    }
+  },
+
   createRecordComponent: function (record, colNum) {
     var field = this.getField(colNum),
         rowNum = this.getRecordIndex(record),
@@ -260,7 +281,7 @@
       clientClass = clientClassArray[0];
       clientClassProps = clientClassArray[1];
 
-      clientClassIsShownInGridEdit = new Function('return ' + clientClass + '.getInstanceProperty("isShownInGridEdit")')();
+      clientClassIsShownInGridEdit = OB.Utilities.getCanvasProp(clientClass, 'isShownInGridEdit');
 
       if (!isEditRecord || clientClassIsShownInGridEdit) {
         canvas = isc.ClassFactory.newInstance(clientClass, {
@@ -285,12 +306,18 @@
   updateRecordComponent: function (record, colNum, component, recordChanged) {
     var field = this.getField(colNum),
         isSummary = record && (record[this.groupSummaryRecordProperty] || record[this.gridSummaryRecordProperty]),
-        rowNum = this.getRecordIndex(record);
+        rowNum = this.getRecordIndex(record),
+        isEditRecord = rowNum === this.getEditRow();
 
     if (isSummary) {
       return null;
     }
 
+    if (isEditRecord && !component.isShownInGridEdit) {
+      //TODO: In OBPickAndExecuteGrid this logic doesn't work very well
+      return null;
+    }
+
     if (field.clientClass) {
       component.align = this.getCellAlign(record, rowNum, colNum);
       component.field = field;
@@ -562,7 +589,7 @@
 
     OBAbsoluteTimeItem_FormatCellValueFunction = function (value, record, rowNum, colNum, grid) {
       var newValue = value,
-          format = isc.OBAbsoluteTimeItem.getPrototype().timeFormatter;
+          format = isc.OBAbsoluteTimeItem.getInstanceProperty('timeFormatter');
       if (Object.prototype.toString.call(newValue) === '[object String]') {
         newValue = isc.Time.parseInput(newValue);
       }
@@ -575,7 +602,7 @@
       var newValue = value;
       newValue = OB.Utilities.Date.addTimezoneOffset(newValue);
       var showTime = false;
-      if (this.editorType && new Function('return isc.' + this.editorType + '.getPrototype().showTime')()) {
+      if (this.editorType && OB.Utilities.getCanvasProp(this.editorType, 'showTime')) {
         showTime = true;
       }
 
@@ -597,17 +624,19 @@
           field.filterEditorProperties.criteriaField = field.criteriaField;
         }
 
-        if (field.criteriaDisplayField) {
-          field.filterEditorProperties.criteriaDisplayField = field.criteriaDisplayField;
+        // send the display property to formitem to be used in request params used to fetch data.
+        // used for displaying table references properly. Refer issue https://issues.openbravo.com/view.php?id=26696
+        if (field.displayProperty) {
+          field.filterEditorProperties.displayProperty = field.displayProperty;
         }
 
-        if (field.editorType && new Function('return isc.' + field.editorType + '.getPrototype().isAbsoluteTime')()) {
+        if (field.editorType && OB.Utilities.getCanvasProp(field.editorType, 'isAbsoluteTime')) {
           // In the case of an absolute time, the time needs to be converted in order to avoid the UTC conversion
           // http://forums.smartclient.com/showthread.php?p=116135
           field.formatCellValue = OBAbsoluteTimeItem_FormatCellValueFunction;
         }
 
-        if (field.editorType && new Function('return isc.' + field.editorType + '.getPrototype().isAbsoluteDateTime')()) {
+        if (field.editorType && OB.Utilities.getCanvasProp(field.editorType, 'isAbsoluteDateTime')) {
           // In the case of an absolute datetime, the JS date needs to be converted in order to avoid the UTC conversion
           // http://forums.smartclient.com/showthread.php?p=116135
           field.formatCellValue = OBAbsoluteDateTimeItem_FormatCellValueFunction;
@@ -620,6 +649,42 @@
           }
           field.formatCellValueFunctionReplaced = true;
           field.formatCellValue = formatCellValueFunction;
+          // if there is a clientClass that expands a grid record, fixedRecordHeight should be false in order to allow the record expansion
+          if (OB.Utilities.getCanvasProp(field.clientClass, 'canExpandRecord')) {
+            this.fixedRecordHeights = false;
+          }
+          // Manage the case the clientClass overwrites the 'canEdit'
+          // If it is not set in the javascript definition of the component, the value returned from the datasource will be used
+          // In case canEdit be true, in grid edition mode the 'editorType' of the component will be rendered.
+          // In case canEdit be false, nothing will be rendered
+          // NOTE: This applies to the editor specified in the component. By default the editor is 'OBClientClassCanvasItem', that means that the editor will be exactly the same
+          //       component than the defined Client Class. You can overwrite the 'editorType' to have a different one. In any case, when 'canEdit' be true, it is desiderable to set
+          //       'isShownInGridEdit' to false, to avoid view two components one above the other.
+          //       As just has been said, if you want to have a particular editor for the edition mode, set 'canEdit' to trie and 'isShownInGridEdit' to false
+          //       If you don't want to see anything in edition mode, just set both 'canEdit' and 'isShownInGridEdit' to false
+          //       If you want to see exactly the same in edition mode than in read mode (no edition capabilities), set 'canEdit' to false and 'isShownInGridEdit' to true
+          if (typeof OB.Utilities.getCanvasProp(field.clientClass, 'canEdit') !== 'undefined' || OB.Utilities.getCanvasProp(field.clientClass, 'canEdit') === null) {
+            field.canEdit = OB.Utilities.getCanvasProp(field.clientClass, 'canEdit');
+          }
+          // Manage the case the clientClass overwrites the 'canSort'
+          if (typeof OB.Utilities.getCanvasProp(field.clientClass, 'canSort') !== 'undefined' || OB.Utilities.getCanvasProp(field.clientClass, 'canSort') === null) {
+            field.canSort = OB.Utilities.getCanvasProp(field.clientClass, 'canSort');
+          }
+          // Manage the case the clientClass overwrites the 'canFilter'
+          if (typeof OB.Utilities.getCanvasProp(field.clientClass, 'canFilter') !== 'undefined' || OB.Utilities.getCanvasProp(field.clientClass, 'canFilter') === null) {
+            field.canFilter = OB.Utilities.getCanvasProp(field.clientClass, 'canFilter');
+          }
+          // Manage the case the clientClass overwrites the 'filterEditorType'
+          if (typeof OB.Utilities.getCanvasProp(field.clientClass, 'filterEditorType') !== 'undefined' || OB.Utilities.getCanvasProp(field.clientClass, 'filterEditorType') === null) {
+            field.filterEditorType = OB.Utilities.getCanvasProp(field.clientClass, 'filterEditorType');
+          }
+          // Manage the case the clientClass overwrites the 'editorType'. 'OBClientClassCanvasItem' by default.
+          if (typeof OB.Utilities.getCanvasProp(field.clientClass, 'editorType') !== 'undefined' || OB.Utilities.getCanvasProp(field.clientClass, 'editorType') === null) {
+            field.editorType = OB.Utilities.getCanvasProp(field.clientClass, 'editorType');
+            if (field.editorProperties) {
+              field.editorProperties.editorType = OB.Utilities.getCanvasProp(field.clientClass, 'editorType');
+            }
+          }
         }
       }
     }
@@ -639,11 +704,12 @@
             delete grid.filterHasChanged;
             delete grid.sortingHasChanged;
             delete grid._filteringAndSortingManually;
-          } else if (!isc.isA.ResultSet(grid.data)) {
+          } else if (!isc.isA.ResultSet(grid.data) || grid.serverDataNotLoaded) {
             // The initial data has not been loaded yet, refreshGrid
             // refreshGrid applies also the current sorting
             grid.refreshGrid();
             delete grid.sortingHasChanged;
+            delete grid.serverDataNotLoaded;
           } else if (grid.sortingHasChanged) {
             grid.setSort(grid.savedSortSpecifiers, true);
             delete grid.sortingHasChanged;
@@ -683,6 +749,9 @@
       }
     }
     if (!keepFilterClause) {
+      if (this.view && this.view.viewGrid) {
+        this.view.viewGrid.fetchingData = true;
+      }
       // forcing fetch from server in case default filters are removed, in other
       // cases adaptive filtering can be used if possible
       if (this.data) {
@@ -928,13 +997,11 @@
       _textMatchStyle: 'substring',
       _UTCOffsetMiliseconds: OB.Utilities.Date.getUTCOffsetInMiliseconds()
     }, lcriteria, this.getFetchRequestParams(null, isExporting));
-    if (this.getSortField()) {
-      sortCriteria = this.getSort();
-      if (sortCriteria && sortCriteria.length > 0) {
-        d._sortBy = sortCriteria[0].property;
-        if (sortCriteria[0].direction === 'descending') {
-          d._sortBy = '-' + d._sortBy;
-        }
+    sortCriteria = this.getSort();
+    if (sortCriteria && sortCriteria.length > 0) {
+      d._sortBy = sortCriteria[0].property;
+      if (sortCriteria[0].direction === 'descending') {
+        d._sortBy = '-' + d._sortBy;
       }
     }
     OB.Utilities.postThroughHiddenForm(dsURL, d);
@@ -1094,6 +1161,156 @@
       return this.Super('getSortArrowImage', arguments);
     }
 
+  },
+
+  collapseRecord: function (record) {
+    var expandedItem = this.getCurrentExpansionComponent(record),
+        ret = this.Super('collapseRecord', arguments);
+    if (expandedItem && typeof expandedItem.destroy === 'function') {
+      expandedItem.destroy();
+    }
+    return ret;
+  },
+
+  //** {{{ openExpansionProcess }}} **
+  //
+  // Opens a process inside a grid row.
+  // Parameters:
+  //  * {{{process}}} The process to be opened
+  //  * {{{record}}} The record where the process will be opened
+  //  * {{{selectOnOpen}}} It indicates if the record will be selected when the process be opened (true by default)
+  //  * {{{deselectAllOnOpen}}} It indicates if all other records will be unselected when the process be opened. It is applied before 'selectOnOpen' (true by default)
+  //  * {{{collapseOthersOnOpen}}} It indicates if any other opened process should be closed (true by default)
+  //  * {{{width}}} The width of the opened process (100% by default)
+  //  * {{{height}}} The height of the opened process (7 grid rows + 'bottom buttons layout' by default)
+  //  * {{{topMargin}}} The top margin of the process. (10 by default)
+  //  * {{{rightMargin}}} The right margin of the process. (30 by default)
+  //  * {{{bottomMargin}}} The bottom margin of the process. (10 by default)
+  //  * {{{leftMargin}}} The left margin of the process. (30 by default)
+  openExpansionProcess: function (process, record, selectOnOpen, deselectAllOnOpen, collapseOthersOnOpen, width, height, topMargin, rightMargin, bottomMargin, leftMargin) {
+    var defaultHeight;
+
+    if (!process || !record) {
+      return;
+    }
+    if (this.fixedRecordHeights) {
+      isc.warn('This grid has "fixedRecordHeights" set to "true". It should be set to "false" in order to view the process', function () {
+        return true;
+      }, {
+        icon: '[SKINIMG]Dialog/error.png',
+        title: OB.I18N.getLabel('OBUIAPP_Error')
+      });
+      return;
+    }
+
+    if (typeof selectOnOpen === 'undefined' || selectOnOpen === null) {
+      selectOnOpen = true;
+    }
+    if (typeof deselectAllOnOpen === 'undefined' || deselectAllOnOpen === null) {
+      deselectAllOnOpen = true;
+    }
+    if (typeof collapseOthersOnOpen === 'undefined' || collapseOthersOnOpen === null) {
+      collapseOthersOnOpen = true;
+    }
+    if (typeof topMargin === 'undefined' || topMargin === null) {
+      topMargin = (process.expandedTopMargin ? process.expandedTopMargin : 10);
+    }
+    if (typeof rightMargin === 'undefined' || rightMargin === null) {
+      rightMargin = (process.expandedRightMargin ? process.expandedRightMargin : 30);
+    }
+    if (typeof bottomMargin === 'undefined' || bottomMargin === null) {
+      bottomMargin = (process.expandedBottomMargin ? process.expandedBottomMargin : 10);
+    }
+    if (typeof leftMargin === 'undefined' || leftMargin === null) {
+      leftMargin = (process.expandedLeftMargin ? process.expandedLeftMargin : 30);
+    }
+
+    if (typeof width === 'undefined' || width === null) {
+      width = (process.expandedWidth ? process.expandedWidth : '100%');
+      if (typeof width === 'string' && width.indexOf('%') === -1) {
+        width = parseInt(width, 10);
+      }
+      if (typeof width === 'number') {
+        width = width + rightMargin + leftMargin;
+      }
+    }
+
+    defaultHeight = isc.OBViewGrid.getPrototype().cellHeight * 6 + //
+    isc.OBViewGrid.getPrototype().filterEditorDefaults.height + //
+    OB.Styles.Process.PickAndExecute.buttonLayoutHeight;
+
+    if (typeof height === 'undefined' || height === null) {
+      height = (process.expandedHeight ? process.expandedHeight : defaultHeight);
+      if (typeof height === 'string' && height.indexOf('%') === -1) {
+        height = parseInt(width, 10);
+      }
+      if (typeof height === 'number') {
+        height = height + topMargin + bottomMargin;
+      }
+    }
+
+    if (deselectAllOnOpen) {
+      this.deselectAllRecords();
+    }
+
+    if (selectOnOpen) {
+      this.selectRecord(record);
+    }
+
+    process.isExpandedRecord = true;
+
+    this.getExpansionComponent = function (theRecord) {
+      var layout = isc.VLayout.create({
+        height: height,
+        width: width,
+        layoutTopMargin: topMargin,
+        layoutRightMargin: rightMargin,
+        layoutBottomMargin: bottomMargin,
+        layoutLeftMargin: leftMargin,
+        members: [process]
+      });
+      return layout;
+    };
+
+    this.canExpandMultipleRecords = !collapseOthersOnOpen;
+
+    this.expandRecord(record);
+
+    this.getExpansionComponent = function () {
+      return;
+    };
+  }
+});
+
+// = OBViewGridBody =
+// OBViewGridBody is used as bodyConstructor for OBGrid, its purpose is to flag 
+// in the grid when fetch data is complete and data is drawn, to be used by automated 
+// Selenium tests
+isc.ClassFactory.defineClass('OBViewGridBody', 'GridBody');
+isc.OBViewGridBody.addProperties({
+  redraw: function () {
+    var newDrawArea, grid, drawArea, firstRecord, loading;
+
+    this.Super('redraw', arguments);
+
+    grid = this.grid;
+    if (grid && grid.fetchingData && grid.body === this) {
+      // check if we are still loading data
+      newDrawArea = this.getDrawArea();
+      drawArea = this._oldDrawArea;
+      if (!drawArea) {
+        drawArea = this._oldDrawArea = [0, 0, 0, 0];
+      }
+
+      firstRecord = grid.getRecord(newDrawArea[0]);
+
+      loading = firstRecord === Array.LOADING;
+
+      if (!loading) {
+        // data is already loaded
+        this.grid.fetchingData = false;
+      }
+    }
   }
 });
 
@@ -1144,7 +1361,21 @@
 });
 
 isc.ClassFactory.defineClass('OBGridFormButton', isc.OBFormButton);
-isc.OBGridFormButton.addProperties({});
+isc.OBGridFormButton.addProperties({
+  showValue: function (displayValue, dataValue, form, item) {
+    if (this.autoFit_orig) {
+      // Restore the autofit attribute if it was set in a first instance to avoid that if the button is
+      // shown as an editor in edition mode (canEdit: true) spans the row width.
+      this.setAutoFit(true);
+    }
+    return this.Super('showValue', arguments);
+  },
+
+  initWidget: function () {
+    this.autoFit_orig = this.autoFit;
+    return this.Super('initWidget', arguments);
+  }
+});
 
 
 isc.defineClass('OBGridLinkCellClick', isc.OBGridLinkItem);
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Wed Sep 03 16:32:14 2014 +0200
@@ -107,7 +107,7 @@
       clientClass = clientClassArray[0];
       clientClassProps = clientClassArray[1];
 
-      clientClassIsShownInGridEdit = new Function('return ' + clientClass + '.getInstanceProperty("isShownInGridEdit")')();
+      clientClassIsShownInGridEdit = OB.Utilities.getCanvasProp(clientClass, 'isShownInGridEdit');
 
       if (!isEditRecord || clientClassIsShownInGridEdit) {
         canvas = isc.ClassFactory.newInstance(clientClass, {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Sep 03 16:32:14 2014 +0200
@@ -963,7 +963,10 @@
 
     if (includeFilter) {
       state.filter = this.getCriteria();
-
+      if (state.filter) {
+        // store the foreign key filter auxiliary cache. this is needed if the grid contains any filter column whose current filter type is 'id'
+        state.filterAuxCache = this.getFKFilterAuxiliaryCache(state.filter);
+      }
       if (!this.filterClause) {
         state.noFilterClause = true;
       }
@@ -993,8 +996,47 @@
     return '(' + isc.Comm.serialize(state, false) + ')';
   },
 
+  // returns an object containing the foreign key filter cache of all the filter fields whose current filter type is 'id'
+  getFKFilterAuxiliaryCache: function (criteria) {
+    var filterField, criterion, filterLength = criteria.criteria.length,
+        fkFilterAuxCache = [],
+        innerCache = [],
+        filterEditForm, cacheElement, i;
+    if (!this.filterEditor || !this.filterEditor.getEditForm()) {
+      return fkFilterAuxCache;
+    }
+    filterEditForm = this.filterEditor.getEditForm();
+    for (i = 0; i < filterLength; i++) {
+      criterion = criteria.criteria[i];
+      filterField = filterEditForm.getField(criterion.fieldName);
+      innerCache = [];
+      if (filterField && filterField.filterType === 'id') {
+        if (criterion.criteria) {
+          for (i = 0; i < criterion.criteria.length; i++) {
+            cacheElement = {};
+            cacheElement.fieldName = criterion.criteria[i].fieldName;
+            cacheElement[OB.Constants.ID] = criterion.criteria[i].value;
+            cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.criteria[i].value);
+            innerCache.add(cacheElement);
+          }
+        } else {
+          cacheElement = {};
+          cacheElement.fieldName = criterion.fieldName;
+          cacheElement[OB.Constants.ID] = criterion.value;
+          cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.value);
+          innerCache.add(cacheElement);
+        }
+        fkFilterAuxCache.add({
+          fieldName: criterion.fieldName,
+          cache: innerCache
+        });
+      }
+    }
+    return fkFilterAuxCache;
+  },
+
   setViewState: function (state, settingDefault) {
-    var localState, i, fld, hasSummaryFunction;
+    var localState, i, fld, hasSummaryFunction, hasDefaultSavedView;
 
     localState = this.evalViewState(state, 'viewState');
 
@@ -1007,6 +1049,10 @@
       return;
     }
 
+    // by default, there are no summary functions
+    hasSummaryFunction = false;
+    this.setShowGridSummary(false);
+
     if (this.getDataSource()) {
       // old versions stored selected records in grid view, this can cause
       // problems if record is not selected yet
@@ -1024,9 +1070,7 @@
             delete fld.summaryFunction;
           }
         }
-        this.setShowGridSummary(hasSummaryFunction);
       }
-
       // remove focus as this results in blur behavior before the
       // (filter)editor is redrawn with new fields when
       // doing setviewstate
@@ -1061,6 +1105,14 @@
 
       this.Super('setViewState', ['(' + isc.Comm.serialize(localState, false) + ')']);
 
+      hasDefaultSavedView = this.view && this.view.standardWindow && this.view.standardWindow.checkIfDefaultSavedView();
+      if (hasSummaryFunction && (!settingDefault || !hasDefaultSavedView)) {
+        // setting summary functions only once, if not causes several requests (see issue #27157)
+        // it is set when setting saved view, or setting defaults (grid configuration) if there is no saved view
+        this.recalculateGridSummary();
+        this.setShowGridSummary(true);
+      }
+
       // Focus on the first filterable item
       if (this.view.isActiveView()) {
         this.focusInFirstFilterEditor();
@@ -1088,6 +1140,8 @@
       if (this.filterEditor && !this.filterEditor.getEditForm()) {
         this.filterEditor.setValuesAsCriteria(localState.filter);
       }
+      // if any filter fields of the stored view was using the 'id' filter type, load its auxiliary cache
+      this.loadFilterAuxiliaryCache(localState.filterAuxCache);
       // this initial criteria needs to be removed in order to properly
       // manage filtering clean up
       this.initialCriteriaSetBySavedView = true;
@@ -1095,6 +1149,22 @@
     }
   },
 
+  // loads the foreign key filter auxiliary cache of all the filter fields that were using the 'id' filter type when the view was saved
+  loadFilterAuxiliaryCache: function (filterAuxCache) {
+    var i, cacheElement, filterField;
+    if (!filterAuxCache || !isc.isA.Array(filterAuxCache) || filterAuxCache.length === 0) {
+      return;
+    }
+    for (i = 0; i < filterAuxCache.length; i++) {
+      cacheElement = filterAuxCache[i];
+      filterField = this.filterEditor.getEditForm().getField(cacheElement.fieldName);
+      filterField.filterType = 'id';
+      if (filterField) {
+        filterField.filterAuxCache = cacheElement.cache;
+      }
+    }
+  },
+
   // overridden to also store the group mode
   // http://forums.smartclient.com/showthread.php?p=93877#post93877
   getGroupState: function () {
@@ -1179,7 +1249,7 @@
   },
 
   setView: function (view) {
-    var dataPageSizeaux, length, i, crit, groupByMaxRecords;
+    var dataPageSizeaux, length, i, crit, groupByMaxRecords, fkCache;
 
     this.view = view;
 
@@ -1204,6 +1274,10 @@
     if (this.view.tabId === this.view.standardWindow.additionalCriteriaTabId && this.view.standardWindow.additionalCriteria) {
       crit = isc.JSON.decode(unescape(this.view.standardWindow.additionalCriteria));
       this.setCriteria(crit);
+      if (this.view.standardWindow.fkCache) {
+        this.fkCache = isc.JSON.decode(unescape(this.view.standardWindow.fkCache));
+        // cannot apply the fkCache yet because the grid might not have a filter editor yet
+      }
       delete this.view.standardWindow.additionalCriteria;
     }
     // if there is no autoexpand field then just divide the space
@@ -1472,6 +1546,12 @@
 
     this.resetEmptyMessage();
     this.view.updateTabTitle();
+    // apply the fk cache to ensure the identifiers of the filtered foreign keys are shown
+    if (this.fkCache) {
+      this.loadFilterAuxiliaryCache(this.fkCache);
+      // delete it to avoid loading the cache more than once
+      delete this.fkCache;
+    }
 
     /*
      * In case the url contains advanced criteria, the initial criteria contains the criteria to be applied. So it should not be deleted.
@@ -1620,6 +1700,12 @@
       this.actionAfterDataArrived = null;
     }
 
+
+    if (this.data.manualResultSet && !this.data.useClientFiltering) {
+      this.data.useClientFiltering = true;
+    }
+    //  update the state of the toolbar buttons, as the availability of some of them depends on the number of records loaded
+    this.view.toolBar.updateButtonState(true);
     return ret;
   },
 
@@ -2023,6 +2109,7 @@
       this.data.totalRows = 0;
       this.data.cachedRows = 0;
     }
+    this.setFechingData();
 
     requestProperties = requestProperties || {};
     requestProperties.params = this.getFetchRequestParams(requestProperties.params);
@@ -2274,7 +2361,8 @@
       menuItems.add({
         title: OB.I18N.getLabel('OBUIAPP_UseAsFilter'),
         click: function () {
-          var value;
+          var value, filterFormItem = grid.filterEditor.getEditForm().getField(field.name),
+              cacheElement = {};
           // a foreign key field, use the displayfield/identifier
           if (field.fkField && field.displayField) {
             value = record[field.displayField];
@@ -2283,10 +2371,19 @@
           }
           // assume a date range filter item
           if (isc.isA.Date(value) && field.filterEditorType === 'OBMiniDateRangeItem') {
-            grid.filterEditor.getEditForm().getField(field.name).setSingleDateValue(value);
+            filterFormItem.setSingleDateValue(value);
           } else {
             grid.filterEditor.getEditForm().setValue(field.name, OB.Utilities.encodeSearchOperator(value));
           }
+          if (field.filterEditorType === 'OBFKFilterTextItem' && filterFormItem) {
+            filterFormItem.filterType = 'id';
+            if (!filterFormItem.getRecordIdentifierFromId(record[field.name])) {
+              // if the filter editor does not know about this record, add the its id and its identifier to the auxiliary filter cache              
+              cacheElement[OB.Constants.ID] = record[field.name];
+              cacheElement[OB.Constants.IDENTIFIER] = record[field.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER];
+              filterFormItem.filterAuxCache.add(cacheElement);
+            }
+          }
           var criteria = grid.filterEditor.getEditForm().getValuesAsCriteria();
           grid.checkShowFilterFunnelIcon(criteria);
           grid.filterData(criteria);
@@ -2348,6 +2445,8 @@
     return false;
   },
 
+
+
   // +++++++++++++++++++++++++++++ Record Selection Handling +++++++++++++++++++++++
   updateSelectedCountDisplay: function () {
     var selection = this.getSelection(),
@@ -2711,6 +2810,11 @@
     } else {
       insertRow = rowNum + 1;
     }
+
+    if (this.lazyFiltering && !isc.isA.ResultSet(this.data)) {
+      OB.Utilities.createResultSetManually(this);
+    }
+
     this.createNewRecordForEditing(insertRow);
     this.startEditing(insertRow);
     this.recomputeCanvasComponents(insertRow);
@@ -3667,8 +3771,6 @@
       } else {
         component.showEditOpen();
       }
-    } else if (isEditRecord) {
-      return null;
     } else {
       return this.Super('updateRecordComponent', arguments);
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Sep 03 16:32:14 2014 +0200
@@ -702,7 +702,7 @@
 
   getDirectLinkUrl: function () {
     var url = window.location.href,
-        crit;
+        crit, fkCache;
     var qIndex = url.indexOf('?');
     var dIndex = url.indexOf('#');
     var index = -1;
@@ -735,6 +735,13 @@
           prettyPrint: false,
           dateFormat: 'dateConstructor'
         }));
+        fkCache = this.viewGrid.getFKFilterAuxiliaryCache(crit);
+        if (isc.isA.Array(fkCache) && fkCache.length > 0) {
+          url = url + '&fkCache=' + escape(isc.JSON.encode(fkCache, {
+            prettyPrint: false,
+            dateFormat: 'dateConstructor'
+          })) + '&';
+        }
       }
     }
 
@@ -755,9 +762,10 @@
 
     this.standardWindow.addView(childView);
 
-    if (this.childTabSet.tabs.length > 0) {
-      // If it is a child tab that is not in the first position, load a basic child view
-      // to ensure a lazy inizialitazion of the contents.
+    if (this.childTabSet.tabs.length > 0 && !this.standardWindow.targetTabId) {
+      // If it is a child tab that is not in the first position and if it is not a
+      // direct navigation to the record (issue 27008), load a basic child view
+      // to ensure a lazy initialization of the contents.
       // Once the tab be selected, the proper content will be loaded.
       this.prepareBasicChildView(childView);
     } else {
@@ -833,7 +841,6 @@
       // the logic doesn't pass through the 'setAsActiveView' so the 'prepareFullChildView' should be done
       // on the tab selection instead.
       me.prepareFullChildView(childView, childTabDef);
-      childTabDef.pane.parentTabSet.doHandleClick();
     };
 
     childTabDef.pane.destroy = function () {
@@ -1763,19 +1770,24 @@
 
   getParentRecord: function () {
     var grid = null;
-    if (!this.parentView || !this.parentView.viewGrid.getSelectedRecords() || this.parentView.viewGrid.getSelectedRecords().length !== 1) {
+    // if there is no parent view, there is no parent record
+    if (!this.parentView) {
       return null;
     }
-
-    // a new parent is not a real parent
-    if (this.parentView.viewGrid.getSelectedRecord()._new) {
-      return null;
-    }
+    // use the standard tree of the tree grid depending on the view being shown
     if (this.parentView.isShowingTree) {
       grid = this.parentView.treeGrid;
     } else {
       grid = this.parentView.viewGrid;
     }
+    // if the parent grid does not have exactly one selected record, return null
+    if (!grid.getSelectedRecords() || grid.getSelectedRecords().length !== 1) {
+      return null;
+    }
+    // a new parent is not a real parent
+    if (!this.parentView.isShowingTree && this.parentView.viewGrid.getSelectedRecord()._new) {
+      return null;
+    }
     return grid.getSelectedRecord();
   },
 
@@ -2489,7 +2501,7 @@
         field = component.getField(propertyObj.property);
         if (field && field.editorType //
         && Object.prototype.toString.call(value) === '[object Date]' //
-        && new Function('return isc.' + field.editorType + '.getPrototype().isAbsoluteDateTime')()) { //
+        && OB.Utilities.getCanvasProp(field.editorType, 'isAbsoluteDateTime')) {
           // In the case of an absolute datetime, it needs to be converted in order to avoid the UTC conversion
           // http://forums.smartclient.com/showthread.php?p=116135
           value = OB.Utilities.Date.addTimezoneOffset(value);
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Wed Sep 03 16:32:14 2014 +0200
@@ -172,6 +172,23 @@
       itemCloseClick: function () {
         return true;
       },
+      setSize: function (width, height) {
+        var me = this;
+        this.hide();
+        // The timeouts are to avoid, as far as possible, ugly resizing effects.
+        setTimeout(function () {
+          me.setWidth(width);
+          me.setHeight(height);
+          if (isc.Browser.isWebKit) { // To avoid strange effect in Chrome when restoring the maximized window (it only happens odd times)
+            me.parentElement.parentElement.parentElement.setWidth('99%');
+            me.parentElement.parentElement.parentElement.setWidth('100%');
+          }
+
+          setTimeout(function () {
+            me.show();
+          }, 1);
+        }, 1);
+      },
       restore: function () {
         this.Super('restore', arguments);
         if (isc.Browser.isWebKit) { // To avoid strange effect in Chrome when restoring the maximized window (it only happens odd times)
@@ -249,13 +266,46 @@
     }
   },
 
-  openProcess: function (params) {
+  buildProcess: function (params) {
     var parts = this.getPrototype().Class.split('_'),
         len = parts.length,
         className = '_',
         tabSet = OB.MainView.TabSet,
-        vStack, manualJS, originalClassName, processClass, processOwnerView;
+        vStack, manualJS, originalClassName, processClass, processOwnerView, runningProcess;
 
+    if (params.paramWindow) {
+      className = className + params.processId;
+      if (len === 3) {
+        // keep original classname in case one with timestamp is not present
+        originalClassName = className;
+
+        // debug mode, we have added _timestamp
+        className = className + '_' + parts[2];
+      }
+
+      processClass = isc[className] || isc[originalClassName];
+
+      if (processClass) {
+        processOwnerView = this.getProcessOwnerView(params.processId);
+        runningProcess = processClass.create(isc.addProperties({}, params, {
+          parentWindow: this,
+          sourceView: this.activeView,
+          buttonOwnerView: processOwnerView
+        }));
+        return runningProcess;
+      } else {
+        isc.warn(OB.I18N.getLabel('OBUIAPP_ProcessClassNotFound', [params.processId]), function () {
+          return true;
+        }, {
+          icon: '[SKINIMG]Dialog/error.png',
+          title: OB.I18N.getLabel('OBUIAPP_Error')
+        });
+      }
+    }
+  },
+
+  openProcess: function (params) {
+    var processOwnerView, selectedState, processToBeOpened;
     if (params.uiPattern === 'M') { // Manual UI Pattern
       try {
         if (isc.isA.Function(params.actionHandler)) {
@@ -266,37 +316,12 @@
         isc.warn(e.message);
       }
     } else {
-      if (params.paramWindow) {
-        className = className + params.processId;
-        if (len === 3) {
-          // keep original classname in case one with timestamp is not present
-          originalClassName = className;
-
-          // debug mode, we have added _timestamp
-          className = className + '_' + parts[2];
-        }
-
-        processClass = isc[className] || isc[originalClassName];
-
-        if (processClass) {
-          processOwnerView = this.getProcessOwnerView(params.processId);
-          this.selectedState = processOwnerView.viewGrid && processOwnerView.viewGrid.getSelectedState();
-          this.runningProcess = processClass.create(isc.addProperties({}, params, {
-            parentWindow: this,
-            sourceView: this.activeView,
-            buttonOwnerView: processOwnerView
-          }));
-
-          this.openPopupInTab(this.runningProcess, params.windowTitle, (this.runningProcess.popupWidth ? this.runningProcess.popupWidth : '90%'), (this.runningProcess.popupHeight ? this.runningProcess.popupHeight : '90%'), (this.runningProcess.showMinimizeButton ? this.runningProcess.showMinimizeButton : false), (this.runningProcess.showMaximizeButton ? this.runningProcess.showMaximizeButton : false), true, true);
-
-        } else {
-          isc.warn(OB.I18N.getLabel('OBUIAPP_ProcessClassNotFound', [params.processId]), function () {
-            return true;
-          }, {
-            icon: '[SKINIMG]Dialog/error.png',
-            title: OB.I18N.getLabel('OBUIAPP_Error')
-          });
-        }
+      processToBeOpened = this.buildProcess(params);
+      if (processToBeOpened) {
+        processOwnerView = this.getProcessOwnerView(params.processId);
+        this.runningProcess = processToBeOpened;
+        this.selectedState = processOwnerView.viewGrid && processOwnerView.viewGrid.getSelectedState();
+        this.openPopupInTab(this.runningProcess, params.windowTitle, (this.runningProcess.popupWidth ? this.runningProcess.popupWidth : '90%'), (this.runningProcess.popupHeight ? this.runningProcess.popupHeight : '90%'), (this.runningProcess.showMinimizeButton ? this.runningProcess.showMinimizeButton : false), (this.runningProcess.showMaximizeButton ? this.runningProcess.showMaximizeButton : false), true, true);
       }
     }
   },
@@ -439,8 +464,8 @@
         view = this.getView(tab.tabId);
         disabledFields = [];
         if (view !== null) {
-          for (i = 0; i < view.viewForm.getFields().length; i++) {
-            field = view.viewForm.getFields()[i];
+          for (i = 0; i < view.formFields.length; i++) {
+            field = view.formFields[i];
             if (tab.fields[field.name] !== undefined) {
               field.updatable = tab.fields[field.name];
               field.disabled = !tab.fields[field.name];
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views.js	Wed Sep 03 16:32:14 2014 +0200
@@ -98,7 +98,7 @@
 // ** {{{OB.Personalization.applyViewDefinition}}} **
 // Apply a selected view definition to a window
 OB.Personalization.applyViewDefinition = function (persId, viewDefinition, standardWindow) {
-  var i, view, viewTabDefinition, showTreeGrid, length = standardWindow.views.length,
+  var i, view, viewTabDefinition, showTreeGrid, selectedView, length = standardWindow.views.length,
       windowDefinition = viewDefinition.window;
 
   // delete the current form personalization 
@@ -107,47 +107,13 @@
 
   standardWindow.selectedPersonalizationId = persId;
 
-  if (windowDefinition) {
-    if (windowDefinition.activeTabId) {
-      for (i = 0; i < length; i++) {
-        if (standardWindow.views[i].tabId === windowDefinition.activeTabId) {
-          view = standardWindow.views[i];
-          break;
-        }
-      }
-      if (view) {
-        // force an active view
-        if (standardWindow.activeView === view) {
-          standardWindow.activeView = null;
-        }
-        view.setAsActiveView(true);
-        if (windowDefinition.parentTabSetState && view.parentTabSet) {
-          view.parentTabSet.setState(windowDefinition.parentTabSetState);
-          view.parentTabSet.setHeight(windowDefinition.parentTabSetHeight);
-          // in this case the visibility of the top part of the parent view has to be set
-          // as it can be hidden previously
-          // https://issues.openbravo.com/view.php?id=18951
-          if (view.parentView && !view.parentView.members[0].isVisible() && isc.OBStandardView.STATE_BOTTOM_MAX !== windowDefinition.parentTabSetState) {
-            view.parentView.members[0].show();
-          }
-        } else if (windowDefinition.childTabSetState && view.childTabSet) {
-          // in this case the visibility of the top part of the view has to be set
-          // as it can be hidden previously
-          // https://issues.openbravo.com/view.php?id=18951
-          if (!view.members[0].isVisible() && isc.OBStandardView.STATE_BOTTOM_MAX !== windowDefinition.childTabSetState) {
-            view.members[0].show();
-          }
-          view.childTabSet.setState(windowDefinition.childTabSetState);
-          view.childTabSet.setHeight(windowDefinition.childTabSetHeight);
-        }
-      }
-    }
-  }
-
   // the viewdefinition contains both the global info (form, canDelete, personalizationid)  
   // set the view state for each tab
   for (i = 0; i < length; i++) {
     view = standardWindow.views[i];
+    if (!selectedView && windowDefinition && windowDefinition.activeTabId && standardWindow.views[i].tabId === windowDefinition.activeTabId) {
+      selectedView = view;
+    }
     viewTabDefinition = viewDefinition[view.tabId];
     if (viewTabDefinition) {
       if (viewTabDefinition.viewMode === 'tree' && view.treeGrid) {
@@ -167,6 +133,35 @@
       }
     }
   }
+
+  if (selectedView) {
+    if (windowDefinition.parentTabSetState && selectedView.parentTabSet) {
+      selectedView.parentTabSet.setState(windowDefinition.parentTabSetState);
+      selectedView.parentTabSet.setHeight(windowDefinition.parentTabSetHeight);
+      // in this case the visibility of the top part of the parent view has to be set
+      // as it can be hidden previously
+      // https://issues.openbravo.com/view.php?id=18951
+      if (selectedView.parentView && !selectedView.parentView.members[0].isVisible() && isc.OBStandardView.STATE_BOTTOM_MAX !== windowDefinition.parentTabSetState) {
+        selectedView.parentView.members[0].show();
+      }
+    } else if (windowDefinition.childTabSetState && selectedView.childTabSet) {
+      // in this case the visibility of the top part of the view has to be set
+      // as it can be hidden previously
+      // https://issues.openbravo.com/view.php?id=18951
+      if (!selectedView.members[0].isVisible() && isc.OBStandardView.STATE_BOTTOM_MAX !== windowDefinition.childTabSetState) {
+        selectedView.members[0].show();
+      }
+      selectedView.childTabSet.setState(windowDefinition.childTabSetState);
+      selectedView.childTabSet.setHeight(windowDefinition.childTabSetHeight);
+    }
+
+    // force an active view
+    if (standardWindow.activeView === selectedView) {
+      standardWindow.activeView = null;
+    }
+    selectedView.setAsActiveView(true);
+  }
+
 };
 
 // ** {{{OB.Personalization.applyViewDefinitionToView}}} **
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalization.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalization.js	Wed Sep 03 16:32:14 2014 +0200
@@ -187,7 +187,7 @@
 
     // for each field create a tree record, a tree record is identified
     // by its name
-    if (isc.isA.SectionItem(fld)) {
+    if (isc.isA.SectionItem(fld) || fld.type === 'OBSectionItem') {
       // section items are shown as folders which can not be dragged
       // or edited
       record = {
@@ -204,12 +204,13 @@
         title: fld.title,
         name: fld.name,
         hiddenInForm: fld.hiddenInForm,
-        startRow: fld.startRow,
-        colSpan: fld.colSpan,
         required: fld.required,
         hasDefaultValue: fld.hasDefaultValue,
-        rowSpan: fld.rowSpan
+        colSpan: (fld.colSpan !== undefined) ? fld.colSpan : 1,
+        rowSpan: (fld.rowSpan !== undefined) ? fld.rowSpan : 1,
+        startRow: (fld.startRow !== undefined) ? fld.startRow : false
       };
+
     }
 
     // is used below to get rid of non-displayed fields which 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-form.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-form.js	Wed Sep 03 16:32:14 2014 +0200
@@ -39,7 +39,7 @@
   // this function is invoked on the blur action of the formitems
   // this is the proper place to execute the client-side callouts
   handleItemChange: function (item) {
-    var affectedParams, i, field;
+    var affectedParams, i, field, me = this;
     // Execute onChangeFunctions if they exist
     if (this && OB.OnChangeRegistry.hasOnChange(this.paramWindow.viewId, item)) {
       OB.OnChangeRegistry.call(this.paramWindow.viewId, item, this.paramWindow, this, this.paramWindow.viewGrid);
@@ -58,8 +58,25 @@
     }
     // evaluate explicitly the display logic for the grid fields
     this.paramWindow.handleDisplayLogicForGridColumns();
-    // force a redraw to reevaluate the display logic of the parameters
-    this.redraw();
-    this.paramWindow.okButton.setEnabled(this.paramWindow.allRequiredParametersSet());
+    this.markForRedraw();
+    // this timeout is needed to ensure that the availability of the ok button is updated after the redrawal of the form because:
+    // - the availability of the ok button must be updated after the form redrawal
+    // - at this point the form cannot be directly redrawn because otherwise the focus does not behave properly, that's why markForRedraw is used
+    // - there is no way to assign a callback to the markForRedraw function
+    setTimeout(function () {
+      me.paramWindow.okButton.setEnabled(me.paramWindow.allRequiredParametersSet());
+    }, 200);
+  },
+
+  setFieldSections: function () {
+    var i, item, length;
+
+    length = this.getItems().length;
+    for (i = 0; i < length; i++) {
+      item = this.getItem(i);
+      if (item && item.setSectionItemInContent) {
+        item.setSectionItemInContent(this);
+      }
+    }
   }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Wed Sep 03 16:32:14 2014 +0200
@@ -51,8 +51,10 @@
     var i, field, items = [],
         buttonLayout = [],
         newButton, cancelButton, view = this,
-        newShowIf, params, updatedExpandSection;
+        newShowIf, context, updatedExpandSection;
 
+    // this flag can be used by Selenium to determine when defaults are set
+    this.defaultsAreSet = false;
 
     // Buttons
 
@@ -121,10 +123,15 @@
 
     if (this.popup) {
       cancelButton = isc.OBFormButton.create({
+        process: this,
         title: OB.I18N.getLabel('OBUISC_Dialog.CANCEL_BUTTON_TITLE'),
         realTitle: '',
         click: function () {
-          view.closeClick();
+          if (this.process.isExpandedRecord) {
+            this.process.callerField.grid.collapseRecord(this.process.callerField.record);
+          } else {
+            view.closeClick();
+          }
         }
       });
       buttonLayout.push(cancelButton);
@@ -245,6 +252,7 @@
           this.isPickAndExecuteWindow = true;
         }
         this.theForm.setItems(items);
+        this.theForm.setFieldSections();
         this.formContainerLayout = isc.OBFormContainerLayout.create({});
         this.formContainerLayout.addMember(this.theForm);
         this.members.push(this.formContainerLayout);
@@ -254,7 +262,8 @@
 
     if (this.popup) {
       this.firstFocusedItem = this.okButton;
-      this.popupButtons = isc.HLayout.create({
+      this.popupButtons = isc.OBFormContainerLayout.create({
+        defaultLayoutAlign: 'center',
         align: 'center',
         width: '100%',
         height: OB.Styles.Process.PickAndExecute.buttonLayoutHeight,
@@ -280,15 +289,12 @@
     this.members.push(this.loading);
     this.Super('initWidget', arguments);
 
-    params = {
-      processId: this.processId
-    };
+    context = this.sourceView ? this.sourceView.getContextInfo(false, true, true, true) : {};
 
-    if (this.sourceView) {
-      params.context = this.sourceView.getContextInfo(false, true, true, true);
-    }
-
-    OB.RemoteCallManager.call('org.openbravo.client.application.process.DefaultsProcessActionHandler', {}, params, function (rpcResponse, data, rpcRequest) {
+    OB.RemoteCallManager.call('org.openbravo.client.application.process.DefaultsProcessActionHandler', context, {
+      processId: this.processId,
+      windowId: this.windowId
+    }, function (rpcResponse, data, rpcRequest) {
       view.handleDefaults(data);
     });
 
@@ -299,7 +305,7 @@
     OB.TestRegistry.register('org.openbravo.client.application.ParameterWindow_FormContainerLayout_' + this.processId, this.formContainerLayout);
   },
 
-  handleResponse: function (refresh, message, responseActions, retryExecution, data) {
+  handleResponse: function (refreshParent, message, responseActions, retryExecution, data) {
     var window = this.parentWindow,
         tab = OB.MainView.TabSet.getTab(this.viewTabId),
         i;
@@ -369,7 +375,7 @@
     if (this.popup && !retryExecution) {
       this.buttonOwnerView.setAsActiveView();
 
-      if (refresh) {
+      if (refreshParent) {
         window.refresh();
       }
 
@@ -459,7 +465,7 @@
         processId: me.processId,
         windowId: me.windowId
       }, function (rpcResponse, data, rpcRequest) {
-        view.handleResponse(true, (data && data.message), (data && data.responseActions), (data && data.retryExecution), data);
+        view.handleResponse(!(data && data.refreshParent === false), (data && data.message), (data && data.responseActions), (data && data.retryExecution), data);
       });
     };
 
@@ -531,6 +537,9 @@
     this.okButton.setEnabled(this.allRequiredParametersSet());
 
     this.handleDisplayLogicForGridColumns();
+
+    // this flag can be used by Selenium to determine when defaults are set
+    this.defaultsAreSet = true;
   },
 
   /**
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Wed Sep 03 16:32:14 2014 +0200
@@ -65,6 +65,10 @@
     return true;
   },
 
+  //** {{{ dataPageSize }}} **
+  // The data page size used for loading paged data from the server.
+  dataPageSize: 100,
+
   initWidget: function () {
     var i, len = this.fields.length,
         theGrid, me = this,
@@ -459,6 +463,9 @@
         record[this.selectionProperty] = true;
         if (this.data.savedData) {
           savedRecord = this.data.savedData.find('id', this.selectedIds[i]);
+          if (!savedRecord) {
+            continue;
+          }
           //Setting editable fields from saved Data to retain values.
           for (j = 0; j < fields.length; j++) {
             if (fields[j].canEdit !== false) {
@@ -551,6 +558,9 @@
       params[OB.Constants.SQL_ORDERBY_PARAMETER] = this.sqlOrderByClause;
     }
 
+    // prevent the count operation
+    params[isc.OBViewGrid.NO_COUNT_PARAMETER] = 'true';
+
     if (this.filterClause) {
       if (props.whereClause) {
         params[OB.Constants.WHERE_PARAMETER] = ' ((' + props.whereClause + ') and (' + this.filterClause + ")) ";
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js	Wed Sep 03 16:32:14 2014 +0200
@@ -106,8 +106,8 @@
           view.viewGrid.startEditingNew(newValues);
         }
       });
+      OB.TestRegistry.register('org.openbravo.client.application.ParameterWindow_Grid_AddNew' + this.parameterName + '_' + this.view.processId, this.addNewButton);
     }
-    OB.TestRegistry.register('org.openbravo.client.application.process.pickandexecute.button.addnew', this.addNewButton);
 
     this.members = [this.messageBar, this.viewGrid, isc.HLayout.create({
       height: 1,
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Wed Sep 03 16:32:14 2014 +0200
@@ -108,7 +108,6 @@
     action: function () {
       var view = this.view,
           grid = view.viewGrid;
-
       // In case of no record selected getRecordIndex(undefined) returns -1,
       // which is the top position, other case it adds bellow current selected row.
       if (grid.getSelectedRecord()) {
@@ -131,7 +130,8 @@
 
   NEW_DOC_BUTTON_PROPERTIES: {
     action: function () {
-      this.view.newDocument();
+      var view = this.view;
+      view.newDocument();
     },
     buttonType: 'newDoc',
     sortPosition: 10,
@@ -242,7 +242,7 @@
     sortPosition: 80,
     prompt: OB.I18N.getLabel('OBUIAPP_ExportGrid'),
     updateState: function () {
-      this.setDisabled(this.view.isShowingForm || this.view.viewGrid.getTotalRows() === 0 || OB.PropertyStore.get("ExportToCsv", this.view.standardWindow.windowId) === 'N');
+      this.setDisabled(this.view.isShowingForm || this.view.viewGrid.getTotalRows() === 0 || OB.PropertyStore.get("ExportToCsv", this.view.standardWindow.windowId) === 'N' || this.view.isShowingTree);
     },
     keyboardShortcutId: 'ToolBar_Export'
   },
@@ -1514,6 +1514,8 @@
     }
   },
 
+
+
   addMembers: 'null',
 
   leftMembers: [],
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-test-registry.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-test-registry.js	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -31,7 +31,11 @@
     };
   }
 
-  var fullUrl = parent.document.URL;
+  var fullUrl = document.URL;
+  try {
+    // To avoid problems trying to run the ERP inside an iframe. Issue 12479
+    fullUrl = parent.document.URL;
+  } catch (ignore) {}
   var queryString = fullUrl.substring(fullUrl.indexOf('?') + 1, fullUrl.length);
   var isTestEnvironment = queryString.indexOf('test=true') !== -1;
   if (isTestEnvironment || OB.Application.testEnvironment) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -67,9 +67,13 @@
 //* {{{msgType}}}: The message type. It can be 'success', 'error', 'info' or 'warning'
 //* {{{msgTitle}}}: The title of the message.
 //* {{{msgText}}}: The text of the message.
+//* {{{force}}}: (Optional) If it should force the message to be show in the popup.
+//               Typically it is used in 'error' cases with 'retryExecution' set as 'true'
 OB.Utilities.Action.set('showMsgInProcessView', function (paramObj) {
   var processView = paramObj._processView;
-  if (processView.popup && processView.buttonOwnerView && processView.buttonOwnerView.messageBar) {
+  if (processView.messageBar && paramObj.force === true) {
+    processView.messageBar.setMessage(paramObj.msgType, paramObj.msgTitle, paramObj.msgText);
+  } else if (processView.popup && processView.buttonOwnerView && processView.buttonOwnerView.messageBar) {
     processView.buttonOwnerView.messageBar.setMessage(paramObj.msgType, paramObj.msgTitle, paramObj.msgText);
   } else if (processView.messageBar) {
     processView.messageBar.setMessage(paramObj.msgType, paramObj.msgTitle, paramObj.msgText);
@@ -114,4 +118,16 @@
       OB.Utilities.Action.resumeThread(paramObj.threadId, 1500); //Call this action again with a 1500ms delay
     }
   }
+});
+
+// ** {{{ setSelectorValueFromRecord }}} **
+// It sets a given value in the selector caller field (if it exists)
+// Parameters:
+// * {{{record}}}: The record to be set in the selector
+OB.Utilities.Action.set('setSelectorValueFromRecord', function (paramObj) {
+  var callerField = paramObj._processView.callerField;
+  if (!callerField) {
+    return;
+  }
+  callerField.setValueFromRecord(paramObj.record, true, true);
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-number.js	Wed Sep 03 16:32:14 2014 +0200
@@ -119,6 +119,9 @@
     return number;
   }
 
+  if (groupInterval === null || groupInterval === undefined) {
+    groupInterval = OB.Format.defaultGroupingSize;
+  }
   // Management of the mask
   if (maskNumeric.indexOf('+') === 0 || maskNumeric.indexOf('-') === 0) {
     maskNumeric = maskNumeric.substring(1, maskNumeric.length);
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Wed Sep 03 16:32:14 2014 +0200
@@ -379,6 +379,9 @@
     if (urlParams.criteria) {
       view.additionalCriteriaTabId = data.tabId;
       view.additionalCriteria = urlParams.criteria;
+      if (urlParams.fkCache) {
+        view.fkCache = urlParams.fkCache;
+      }
     }
 
     if (urlParams.replaceDefaultFilter) {
@@ -1079,6 +1082,25 @@
   return ret;
 };
 
+//** {{{ OB.Utilities.getCanvasProp }}} **
+//
+// Returns the value of the property of the canvas item
+// Parameters:
+//  * {{{canvas}}} String the canvas item
+//  * {{{prop}}} String the property to get the value
+OB.Utilities.getCanvasProp = function (canvas, prop) {
+  if (canvas.indexOf('{') !== -1) {
+    canvas = OB.Utilities.clientClassSplitProps(canvas)[0];
+  }
+  if (new Function('if (window.' + canvas + ') { return true; }')()) {
+    if (new Function('if (typeof ' + canvas + '.getInstanceProperty === "function") { return true; }')()) {
+      // 'getInstanceProperty' is a Smartclient function to determine the property value of a canvas
+      return new Function('return ' + canvas + '.getInstanceProperty("' + prop + '")')();
+    }
+  }
+  return;
+};
+
 
 //** {{{ OB.Utilities.getRGBAStringFromOBColor }}} **
 //
@@ -1247,4 +1269,38 @@
     }
   }
   return -1;
+};
+
+//** {{{ OB.Utilities.getObjectSize }}} **
+//
+// Returns the size of an object (only the first level)
+// Parameters:
+//  * {{{object}}} The object to get the size
+OB.Utilities.getObjectSize = function (object) {
+  var size = 0,
+      key;
+  if (Object.prototype.toString.call(object) !== '[object Object]') {
+    return false;
+  }
+  for (key in object) {
+    if (object.hasOwnProperty(key)) {
+      size++;
+    }
+  }
+  return size;
+};
+
+//** {{{ OB.Utilities.createResultSetManually }}} **
+//
+// Creates a ResultSet manually for a grid
+// Parameters:
+//  * {{{grid}}} The grid whose ResultSet will be created manually
+OB.Utilities.createResultSetManually = function (grid) {
+  grid.dataProperties.dataSource = grid.dataSource;
+  grid.dataProperties.initialData = [];
+  grid.dataProperties.resultSize = 100;
+  grid.dataProperties.useClientFiltering = false;
+  grid.dataProperties.manualResultSet = true;
+  grid.setData(grid.createDataModel());
+  grid.serverDataNotLoaded = true;
 };
\ No newline at end of file
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/add_icon.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/add_icon_Disabled.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/add_icon_Disabled_orig.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/add_icon_Down.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/add_icon_Over.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/levelImg_0_4.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/levelImg_1_4.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/levelImg_2_4.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/levelImg_3_4.png has changed
Binary file modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/levelImg_4_4.png has changed
--- a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-process-styles.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-process-styles.js	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -27,5 +27,5 @@
   iconDeleteSrc: OB.Styles.skinsPath + 'Default/org.openbravo.client.application/images/process/iconDelete.png',
   iconDeleteStyle: 'OBProcessIconDeleteImg',
   addNewButtonAlign: 'left',
-  buttonLayoutHeight: 80
+  buttonLayoutHeight: 60
 };
\ No newline at end of file
--- a/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <NAME><![CDATA[HTML Widget]]></NAME>
-<!--D393BE6F22BB44B7B728259B34FC795A-->  <VERSION><![CDATA[1.0.23921]]></VERSION>
+<!--D393BE6F22BB44B7B728259B34FC795A-->  <VERSION><![CDATA[1.0.24368]]></VERSION>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <DESCRIPTION><![CDATA[Provides the HTML Widget superclass that allows to create widget classes that embed the html code.]]></DESCRIPTION>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <HELP><![CDATA[With this module you can define your own widget classes just setting up your own html code or the html code provided by third parties.]]></HELP>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <URL><![CDATA[http://forge.openbravo.com/projects/htmlwidget]]></URL>
--- a/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <AD_MODULE_ID><![CDATA[D393BE6F22BB44B7B728259B34FC795A]]></AD_MODULE_ID>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--DCE798FBC5B648F7A3C81A6941720A57-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--DCE798FBC5B648F7A3C81A6941720A57-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <DEPENDANT_MODULE_NAME><![CDATA[My Openbravo Tab]]></DEPENDANT_MODULE_NAME>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--4B828F4D03264080AA1D2057B13F613C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <NAME><![CDATA[User Interface Client Kernel]]></NAME>
-<!--4B828F4D03264080AA1D2057B13F613C-->  <VERSION><![CDATA[2.1.23921]]></VERSION>
+<!--4B828F4D03264080AA1D2057B13F613C-->  <VERSION><![CDATA[2.1.24368]]></VERSION>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <DESCRIPTION><![CDATA[Provides framework functionality for the Openbravo User Interface]]></DESCRIPTION>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <HELP><![CDATA[The user interface client kernel is a generation framework for generating client (browser) components used in Openbravo. Its components are mainly used by other modules to provide customizable and extendable user interfaces.]]></HELP>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <URL><![CDATA[http://forge.openbravo.com/projects/openbravoclientkernel]]></URL>
--- a/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--26B041893E844A53AFA58BC326C4F0D7-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--26B041893E844A53AFA58BC326C4F0D7-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_DEPENDENT_MODULE_ID>
-<!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <STARTVERSION><![CDATA[1.1.23921]]></STARTVERSION>
+<!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <STARTVERSION><![CDATA[1.1.24368]]></STARTVERSION>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <DEPENDANT_MODULE_NAME><![CDATA[JBoss Weld]]></DEPENDANT_MODULE_NAME>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <AD_DEPENDENT_MODULE_ID><![CDATA[F8D1B3ECB3474E8DA5C216473C840DF1]]></AD_DEPENDENT_MODULE_ID>
-<!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <STARTVERSION><![CDATA[2.0.23921]]></STARTVERSION>
+<!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <STARTVERSION><![CDATA[2.0.24368]]></STARTVERSION>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON REST Webservice]]></DEPENDANT_MODULE_NAME>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/FreemarkerTemplateProcessorTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/FreemarkerTemplateProcessorTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,6 +19,9 @@
 
 package org.openbravo.client.kernel.freemarker.test;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.net.URL;
@@ -30,6 +33,7 @@
 
 import javax.inject.Inject;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
@@ -64,9 +68,9 @@
   @TemplateProcessor.Qualifier(FreemarkerTemplateProcessor.QUALIFIER)
   private TemplateProcessor templateProcessor;
 
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpFt() throws Exception {
+    // super.setUp();
 
     // after super.setUp, must be done after initializing dal layer in super class
     final Entity entity = ModelProvider.getInstance().getEntity(Template.ENTITY_NAME);
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/GenerateComponentTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/GenerateComponentTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/LabelTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/LabelTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,10 +19,14 @@
 
 package org.openbravo.client.kernel.freemarker.test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.util.HashMap;
 
 import javax.inject.Inject;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.weld.test.WeldBaseTest;
@@ -52,8 +56,9 @@
   @ComponentProvider.Qualifier(KernelComponentProvider.QUALIFIER)
   private ComponentProvider kernelComponentProvider;
 
-  public void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUpLt() throws Exception {
+    // super.setUp();
     setSystemAdministratorContext();
   }
 
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/CompressionTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/CompressionTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,12 +19,16 @@
 
 package org.openbravo.client.kernel.test;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
+import org.junit.Test;
 import org.openbravo.client.kernel.JSCompressor;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * Test the compression of a static js file.
@@ -32,8 +36,9 @@
  * @author mtaal
  */
 
-public class CompressionTest extends BaseTest {
+public class CompressionTest extends OBBaseTest {
 
+  @Test
   public void testCompression() throws Exception {
     final JSCompressor compressor = new JSCompressor();
     final InputStream is = this.getClass().getResourceAsStream("test-compression.js");
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/KernelUtilTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/KernelUtilTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,13 +19,18 @@
 
 package org.openbravo.client.kernel.test;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.List;
 
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.client.kernel.KernelUtils;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.module.Module;
 import org.openbravo.model.ad.module.ModuleDependency;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * Test the {@link KernelUtils} class.
@@ -33,15 +38,17 @@
  * @author mtaal
  */
 
-public class KernelUtilTest extends BaseTest {
+public class KernelUtilTest extends OBBaseTest {
 
   private static void initializeStatics() {
   }
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-
+  /** 
+   * This before method is named setUpK() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   */
+  @Before
+  public void setUpK() throws Exception {
     // after super.setUp, must be done after initializing dal layer in super class
     initializeStatics();
   }
@@ -49,6 +56,7 @@
   /**
    * Tests {@link KernelUtils#getModulesOrderedByDependency()}.
    */
+  @Test
   public void testModulesOrderByDependency() throws Exception {
     setSystemAdministratorContext();
     final List<Module> modules = KernelUtils.getInstance().getModulesOrderedByDependency();
@@ -76,6 +84,7 @@
    * 
    * @throws Exception
    */
+  @Test
   public void testVersionId() throws Exception {
     setSystemAdministratorContext();
     try {
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/TemplateResolverTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/TemplateResolverTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,10 +19,14 @@
 
 package org.openbravo.client.kernel.test;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.junit.Before;
+import org.junit.Test;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
@@ -31,7 +35,7 @@
 import org.openbravo.client.kernel.TemplateDependency;
 import org.openbravo.client.kernel.TemplateResolver;
 import org.openbravo.dal.service.OBDal;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
 /**
  * Test the {@link TemplateResolver}.
@@ -43,7 +47,7 @@
  * @author mtaal
  */
 
-public class TemplateResolverTest extends BaseTest {
+public class TemplateResolverTest extends OBBaseTest {
   private static final List<Template> EMPTY_LIST = Collections.emptyList();
 
   // read some default values used in the test
@@ -60,10 +64,12 @@
     COMPONENT_TYPE = componentTypeProperty.getAllowedValues().iterator().next();
   }
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-
+  /** 
+   * This before method is named setUpT() to avoid overwriting the super 
+   * setUp method that is invoke automatically before this one.
+   */
+  @Before
+  public void setUpT() throws Exception {
     // after super.setUp, must be done after initializing dal layer in super class
     initializeStatics();
   }
@@ -76,6 +82,7 @@
    * 
    * Then the returned result is computed depth-first: D, E, B, F, G, C, A
    */
+  @Test
   public void testResolveDependencies() throws Exception {
     setSystemAdministratorContext();
 
@@ -118,6 +125,7 @@
    * 
    * @throws Exception
    */
+  @Test
   public void testResolveDependenciesWithOverrides() throws Exception {
     setUserContext("0");
 
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseKernelServlet.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseKernelServlet.java	Wed Sep 03 16:32:14 2014 +0200
@@ -68,9 +68,14 @@
 
     if (localResponse.getRedirectTarget() != null) {
       if (!response.isCommitted()) {
+        // get where the request originated
+        String referer = RequestContext.get().getRequest().getHeader("referer");
+        // if we can't get where the request originated, redirect to the ERP
+        if (referer == null) {
+          referer = localResponse.getRedirectTarget();
+        }
         // will this always work.... not if the writer is already closed
-        response.getWriter().write(
-            "window.location.href = '" + localResponse.getRedirectTarget() + "';");
+        response.getWriter().write("window.location.href = '" + referer + "';");
         response.setHeader("Content-Type", KernelConstants.JAVASCRIPT_CONTENTTYPE);
         // prevent caching
         response.setHeader(RESPONSE_HEADER_ETAG, "" + System.currentTimeMillis());
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelApplicationInitializer.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelApplicationInitializer.java	Wed Sep 03 16:32:14 2014 +0200
@@ -37,5 +37,7 @@
         new StandardSQLFunction("ad_org_getcalendarowner", new StringType()));
     OBDal.getInstance().registerSQLFunction("ad_org_getperiodcontrolallow",
         new StandardSQLFunction("ad_org_getperiodcontrolallow", new StringType()));
+    OBDal.getInstance().registerSQLFunction("m_isparent_ch_value",
+        new StandardSQLFunction("m_isparent_ch_value", new StringType()));
   }
 }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelComponentProvider.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelComponentProvider.java	Wed Sep 03 16:32:14 2014 +0200
@@ -37,6 +37,8 @@
 public class KernelComponentProvider extends BaseComponentProvider {
   public static final String QUALIFIER = KernelConstants.KERNEL_COMPONENT_TYPE;
 
+  private List<ComponentResource> globalResources = null;
+
   /*
    * (non-Javadoc)
    * 
@@ -80,8 +82,13 @@
     return versionParam;
   }
 
-  public List<ComponentResource> getGlobalComponentResources() {
-    final List<ComponentResource> globalResources = new ArrayList<ComponentResource>();
+  @Override
+  public synchronized List<ComponentResource> getGlobalComponentResources() {
+    if (globalResources != null) {
+      return globalResources;
+    }
+    globalResources = new ArrayList<ComponentResource>();
+
     globalResources.add(createStaticResource("org.openbravo.client.kernel/"
         + KernelConstants.KERNEL_COMPONENT_TYPE + "/" + KernelConstants.APPLICATION_COMPONENT_ID,
         true));
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Wed Sep 03 16:32:14 2014 +0200
@@ -51,7 +51,7 @@
  */
 public class KernelServlet extends BaseKernelServlet {
   // private static final Logger log = Logger.getLogger(DataSourceServlet.class);
-  private static final Logger log4j = Logger.getLogger(KernelServlet.class);
+  private static final Logger log = Logger.getLogger(KernelServlet.class);
 
   // this is needed to support logout deep in the code...
   // TODO: make it easier to get to the authentication manager from
@@ -81,6 +81,48 @@
     return servletPathPart;
   }
 
+  // the inc and dec by passauthentication count must be synchronized
+  // and static, there might be multiple kernelservlets and multiple threads
+  // may use the same kernelservlet
+  // TODO: synchronize on the session object instead of on a static
+  protected static synchronized void incBypassAuthenticationCount(HttpServletRequest request) {
+    HttpSession session = request.getSession(true);
+    OBContext context = OBContext.getOBContext();
+    boolean sessionForThisRequest = context == null
+        || session.getAttribute("#Authenticated_user") == null;
+
+    if (sessionForThisRequest) {
+      session.setAttribute("forceLogin", "Y");
+    }
+
+    if (session != null && "Y".equals(session.getAttribute("forceLogin"))) {
+      // session has been created to retrieve a non authenticated component, it might be several
+      // non authenticated components sharing the same session, count them to invalidate the
+      // session after all of them are done
+      Integer count = (Integer) session.getAttribute("forcedSessionsRequestCount");
+      if (count == null || count == 0) {
+        count = 1;
+      } else {
+        count += 1;
+      }
+      session.setAttribute("forcedSessionsRequestCount", count);
+    }
+  }
+
+  protected static synchronized void decBypassAuthenticationCount(HttpSession session) {
+    if (session != null && "Y".equals(session.getAttribute("forceLogin"))) {
+      Integer count = (Integer) session.getAttribute("forcedSessionsRequestCount");
+      count = (count != null ? count : 0) - 1;
+
+      if (count <= 0) {
+        session.invalidate();
+        log.debug("Invalidating session created for bypass authentication elements");
+      } else {
+        session.setAttribute("forcedSessionsRequestCount", count);
+      }
+    }
+  }
+
   @Inject
   @Any
   private Instance<ComponentProvider> componentProviders;
@@ -97,7 +139,6 @@
   public void service(final HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
 
-    boolean sessionForThisRequest = false;
     boolean bypassAuthentication = false;
 
     final String action = request.getParameter(KernelConstants.ACTION_PARAMETER);
@@ -106,34 +147,7 @@
 
       if (component instanceof BaseComponent && ((BaseComponent) component).bypassAuthentication()) {
         bypassAuthentication = true;
-        OBContext context = OBContext.getOBContext();
-
-        sessionForThisRequest = context == null
-            || request.getSession().getAttribute("#Authenticated_user") == null;
-
-        HttpSession session = request.getSession(true);
-        if (sessionForThisRequest) {
-          // creating session for this request marked as forceLogin
-          session = request.getSession(true);
-          session.setAttribute("forceLogin", "Y");
-        } else {
-          // there is already a session, don't touch it
-          session = request.getSession(false);
-        }
-
-        if (session != null && "Y".equals(session.getAttribute("forceLogin"))) {
-          // session has been created to retrieve a non authenticated component, it might be several
-          // non authenticated components sharing the same session, count them to invalidate the
-          // session after all of them are done
-          Integer count = (Integer) session.getAttribute("forcedSessionsRequestCount");
-          if (count == null || count == 0) {
-            count = 1;
-          } else {
-            count += 1;
-          }
-          session.setAttribute("forcedSessionsRequestCount", count);
-        }
-
+        incBypassAuthenticationCount(request);
       }
     }
 
@@ -141,17 +155,7 @@
 
     if (bypassAuthentication) {
       HttpSession session = request.getSession(false);
-      if (session != null && "Y".equals(session.getAttribute("forceLogin"))) {
-        Integer count = (Integer) session.getAttribute("forcedSessionsRequestCount");
-        count = (count != null ? count : 0) - 1;
-
-        if (count <= 0) {
-          session.invalidate();
-          log4j.debug("Invalidating session created for bypass authentication elements");
-        } else {
-          session.setAttribute("forcedSessionsRequestCount", count);
-        }
-      }
+      decBypassAuthenticationCount(session);
     }
   }
 
@@ -229,7 +233,7 @@
       pw.write(result);
       pw.close();
     } catch (Exception e) {
-      log4j.error(e.getMessage(), e);
+      log.error(e.getMessage(), e);
       if (!response.isCommitted()) {
         response.setContentType(KernelConstants.JAVASCRIPT_CONTENTTYPE);
         response.setHeader(RESPONSE_HEADER_CONTENTTYPE, KernelConstants.JAVASCRIPT_CONTENTTYPE);
@@ -261,7 +265,7 @@
 
       if (OBContext.getOBContext() != null && OBContext.getOBContext().isPortalRole()) {
         if (!(actionHandler instanceof PortalAccessible)) {
-          log4j.error("Portal user " + OBContext.getOBContext().getUser() + " with role "
+          log.error("Portal user " + OBContext.getOBContext().getUser() + " with role "
               + OBContext.getOBContext().getRole()
               + " is trying to access to non granted action handler " + request.getRequestURL()
               + "?" + request.getQueryString());
@@ -271,7 +275,7 @@
 
       actionHandler.execute();
     } catch (Exception e) {
-      log4j.error("Error executing action " + action + " error: " + e.getMessage(), e);
+      log.error("Error executing action " + action + " error: " + e.getMessage(), e);
       if (!response.isCommitted()) {
         response.setContentType(KernelConstants.JAVASCRIPT_CONTENTTYPE);
         response.setHeader(RESPONSE_HEADER_CONTENTTYPE, KernelConstants.JAVASCRIPT_CONTENTTYPE);
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java	Wed Sep 03 16:32:14 2014 +0200
@@ -502,4 +502,22 @@
     }
     return targetColumnName;
   }
+
+  /**
+   * Returns true if any of the identifier properties of the provided entity is nullable
+   * 
+   * @param entity
+   *          entity whose identifier might be comprised by nullable properties
+   * @return true if at least one of the identifier properties of the provided entity is nullable,
+   *         false if all of them are mandatory
+   */
+  public static boolean hasNullableIdentifierProperties(Entity entity) {
+    List<Property> identifierProperties = entity.getIdentifierProperties();
+    for (Property property : identifierProperties) {
+      if (!property.isMandatory()) {
+        return true;
+      }
+    }
+    return false;
+  }
 }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Wed Sep 03 16:32:14 2014 +0200
@@ -30,6 +30,7 @@
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.log4j.Logger;
+import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource.ComponentResourceType;
 import org.openbravo.dal.core.OBContext;
@@ -224,6 +225,29 @@
     }
 
     if (!"".equals(sb.toString())) {
+      final String referer = RequestContext.get().getRequest().getHeader("referer");
+      /*
+       * If a module is in development or the application is running the tests, add the isDebug
+       * variable to the generated javascript file.
+       * 
+       * If the isDebug variable is present in the javascript files, the code that calls
+       * OB.UTIL.Debug will not be executed
+       * 
+       * This option is intended to run additional code (checks, etc) that will not be run while in
+       * production.
+       * 
+       * This improves performance at the same time that the developer have a tool to improve
+       * stability.
+       * 
+       * TODO: add an algorithm to remove the OB.UTIL.Debug code and calls from the generated
+       * javacript file
+       * 
+       * TODO: don't load the ob-debug.js file if not in use
+       */
+      if (isInDevelopment()
+          || OBPropertiesProvider.getInstance().getBooleanProperty("test.environment")) {
+        sb.insert(0, "var isDebug = true;\n\n");
+      }
       sb.append("if (window.onerror && window.onerror.name === '"
           + KernelConstants.BOOTSTRAP_ERROR_HANDLER_NAME + "') { window.onerror = null; }");
       sb.append("if (typeof OBStartApplication !== 'undefined' && Object.prototype.toString.call(OBStartApplication) === '[object Function]') { OBStartApplication(); }");
@@ -242,7 +266,8 @@
     // when changing development status, system needs to be restarted.
     final String output;
     // in classicmode the isc combined is included, compressing that gives errors
-    if (!isInDevelopment() && !isClassicMode()) {
+    if (!isInDevelopment() && !isClassicMode()
+        && !OBPropertiesProvider.getInstance().getBooleanProperty("test.environment")) {
       output = JSCompressor.getInstance().compress(sb.toString());
     } else {
       output = sb.toString();
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java	Wed Sep 03 16:32:14 2014 +0200
@@ -19,20 +19,31 @@
 
 package org.openbravo.client.kernel.reference;
 
+import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.Sqlc;
+import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.model.ad.ui.Field;
+import org.openbravo.model.ad.utility.Tree;
+import org.openbravo.model.ad.utility.TreeNode;
+import org.openbravo.model.common.plm.CharacteristicValue;
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.model.common.plm.ProductCharacteristicValue;
 
 public class CharacteristicsUIDefinition extends TextUIDefinition {
 
+  private static final Logger log4j = Logger.getLogger(CharacteristicsUIDefinition.class);
+
   @Override
   public String getFormEditorType() {
     return "OBCharacteristicsItem";
@@ -75,8 +86,8 @@
 
       JSONObject jsonValue = new JSONObject();
       for (ProductCharacteristicValue charValue : product.getProductCharacteristicValueList()) {
-        jsonValue.put(charValue.getCharacteristic().getIdentifier(), charValue
-            .getCharacteristicValue().getIdentifier());
+        jsonValue.put(charValue.getCharacteristic().getIdentifier(),
+            getValue(charValue.getCharacteristicValue()));
       }
 
       value.put("characteristics", jsonValue);
@@ -91,4 +102,52 @@
     }
   }
 
+  private String getValue(CharacteristicValue characValue) {
+    int levels = 0;
+
+    try {
+      String levelsPreference = Preferences.getPreferenceValue("ShowProductCharacteristicsParents",
+          true, OBContext.getOBContext().getCurrentClient(), OBContext.getOBContext()
+              .getCurrentOrganization(), OBContext.getOBContext().getUser(), OBContext
+              .getOBContext().getRole(), null);
+      levels = Integer.parseInt(levelsPreference);
+    } catch (Exception e) {
+      if (e instanceof NumberFormatException) {
+        log4j.error("ShowProductCharacteristicsParents preference is not a number", e);
+      } else {
+        log4j.error("Error finding ShowProductCharacteristicsParents preference", e);
+      }
+    }
+
+    String value = characValue.getIdentifier();
+    if (levels > 0) {
+      CharacteristicValue currentCharValue = characValue;
+      int i = 0;
+      boolean existsParent = true;
+
+      while (i < levels && existsParent) {
+        existsParent = false;
+        // Find parent
+        OBCriteria<TreeNode> treeNodeCri = OBDal.getInstance().createCriteria(TreeNode.class);
+        treeNodeCri.createAlias(TreeNode.PROPERTY_TREE, "tree");
+        treeNodeCri.add(Restrictions.eq("tree." + Tree.PROPERTY_CLIENT, OBContext.getOBContext()
+            .getCurrentClient()));
+        treeNodeCri.add(Restrictions.eq("tree." + Tree.PROPERTY_TYPEAREA, "CH"));
+        treeNodeCri.add(Restrictions.eq(TreeNode.PROPERTY_NODE, currentCharValue.getId()));
+        List<TreeNode> treeNodeList = treeNodeCri.list();
+        if (treeNodeList.size() == 1 && !treeNodeList.get(0).getReportSet().equals("0")) {
+          // Parent Exists
+          currentCharValue = OBDal.getInstance().get(CharacteristicValue.class,
+              treeNodeList.get(0).getReportSet());
+          value = currentCharValue.getIdentifier() + " / " + value;
+          existsParent = true;
+        }
+        i++;
+      }
+
+    }
+
+    return value;
+  }
+
 }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java	Wed Sep 03 16:32:14 2014 +0200
@@ -25,6 +25,7 @@
 import org.openbravo.client.kernel.KernelUtils;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.model.ad.datamodel.Column;
+import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.ad.domain.Reference;
 import org.openbravo.model.ad.domain.ReferencedTable;
 import org.openbravo.model.ad.ui.Field;
@@ -59,16 +60,21 @@
       Reference referenceSearchKey = column.getReferenceSearchKey();
       if (referenceSearchKey != null && referenceSearchKey.getADReferencedTableList().size() > 0) {
         ReferencedTable referencedTable = referenceSearchKey.getADReferencedTableList().get(0);
-        // set the criteriaDisplayField in all cases, as the display column need not be part of
-        // identifier. Refer issue https://issues.openbravo.com/view.php?id=26696
         if (referencedTable != null) {
           Property prop = KernelUtils.getInstance().getPropertyFromColumn(column);
           Property referencedProp = KernelUtils.getInstance().getPropertyFromColumn(
               referencedTable.getDisplayedColumn());
           if (prop != null && referencedProp != null) {
-            criteriaField = ", criteriaField: " + "'" + prop.getName() + DalUtil.FIELDSEPARATOR
-                + referencedProp.getName() + "', criteriaDisplayField: '"
-                + referencedProp.getName() + "'";
+            if (isTableWithMultipleIdentifierColumns(referencedTable.getTable())) {
+              criteriaField = ", criteriaField: " + "'" + prop.getName() + DalUtil.FIELDSEPARATOR
+                  + referencedProp.getName() + "', criteriaDisplayField: '"
+                  + referencedProp.getName() + "'";
+            }
+            // always pass the display property in case of table references. This is used to fetch
+            // the record properly in grid filter.
+            // refer issue https://issues.openbravo.com/view.php?id=26696
+            criteriaField = criteriaField.concat(", displayProperty: '" + referencedProp.getName()
+                + "'");
           }
         }
       }
@@ -76,6 +82,22 @@
     return super.getGridFieldProperties(field) + criteriaField;
   }
 
+  /* Returns true if the identifier of the table is composed of more than one column */
+  private Boolean isTableWithMultipleIdentifierColumns(Table relatedTable) {
+    int nIdentifiers = 0;
+    for (Column curColumn : relatedTable.getADColumnList()) {
+      if (curColumn.isIdentifier()) {
+        nIdentifiers += 1;
+        if (nIdentifiers > 1) {
+          // if there is more than one identifier return true
+          return true;
+        }
+      }
+    }
+    // there is only one identifier column
+    return false;
+  }
+
   @Override
   public String getFieldProperties(Field field, boolean getValueFromSession) {
     JSONObject value;
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Wed Sep 03 16:32:14 2014 +0200
@@ -63,6 +63,11 @@
       }
     }
 
+    Boolean allowFkFilterByIdentifier = (Boolean) readGridConfigurationSetting("allowFkFilterByIdentifier");
+    if (Boolean.FALSE.equals(allowFkFilterByIdentifier)) {
+      append = append + ", allowFkFilterByIdentifier: " + allowFkFilterByIdentifier.toString();
+    }
+
     return super.getFilterEditorPropertiesProperty(field) + append;
   }
 
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java	Wed Sep 03 16:32:14 2014 +0200
@@ -574,13 +574,31 @@
       values.addAll(Arrays.asList(fps));
       ArrayList<JSONObject> comboEntries = new ArrayList<JSONObject>();
       ArrayList<String> possibleIds = new ArrayList<String>();
-      // If column is mandatory we add an initial blank value
-      if (!field.getColumn().isMandatory() && StringUtils.isEmpty(columnValue)) {
-        possibleIds.add("");
-        JSONObject entry = new JSONObject();
-        entry.put(JsonConstants.ID, (String) null);
-        entry.put(JsonConstants.IDENTIFIER, (String) null);
-        comboEntries.add(entry);
+      // If column is not mandatory we add an initial blank value
+      if (!field.getColumn().isMandatory()) {
+        // check if column value is present and is the first selected value.
+        // If yes, no need for the blank value as it is the single value to be set.
+        if (!StringUtils.isEmpty(columnValue) && !isListReference) {
+          if (values.size() > 0 && values.get(0).getField(JsonConstants.ID) != null) {
+            if (!columnValue.equals(values.get(0).getField(JsonConstants.ID))) {
+              possibleIds.add("");
+              JSONObject entry = new JSONObject();
+              entry.put(JsonConstants.ID, (String) null);
+              entry.put(JsonConstants.IDENTIFIER, (String) null);
+              comboEntries.add(entry);
+              // only one value has to be set if column value is present, but since it is not
+              // present in the valueMap clearing it and setting empty value.
+              // Refer issue https://issues.openbravo.com/view.php?id=27061
+              values = new ArrayList<FieldProvider>();
+            }
+          }
+        } else {
+          possibleIds.add("");
+          JSONObject entry = new JSONObject();
+          entry.put(JsonConstants.ID, (String) null);
+          entry.put(JsonConstants.IDENTIFIER, (String) null);
+          comboEntries.add(entry);
+        }
       }
       for (FieldProvider fp : values) {
         possibleIds.add(fp.getField("ID"));
--- a/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <NAME><![CDATA[Workspace & Widgets]]></NAME>
-<!--2758CD25B2704AF6BBAD10365FC82C06-->  <VERSION><![CDATA[2.1.23921]]></VERSION>
+<!--2758CD25B2704AF6BBAD10365FC82C06-->  <VERSION><![CDATA[2.1.24368]]></VERSION>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <DESCRIPTION><![CDATA[Workspace & Widgets]]></DESCRIPTION>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <HELP><![CDATA[Provides the infrastructure of workspace tab (formerly My Openbravo)]]></HELP>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <URL><![CDATA[http://forge.openbravo.com/projects/myopenbravo]]></URL>
--- a/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--15F51F03882F444CAB6593B4566DC929-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--15F51F03882F444CAB6593B4566DC929-->  <AD_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_MODULE_ID>
 <!--15F51F03882F444CAB6593B4566DC929-->  <AD_DEPENDENT_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_DEPENDENT_MODULE_ID>
-<!--15F51F03882F444CAB6593B4566DC929-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--15F51F03882F444CAB6593B4566DC929-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--15F51F03882F444CAB6593B4566DC929-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--15F51F03882F444CAB6593B4566DC929-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Application]]></DEPENDANT_MODULE_NAME>
 <!--15F51F03882F444CAB6593B4566DC929-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <AD_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_MODULE_ID>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--E71B28FC949D481D9F59C17D01E46EF9-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--E71B28FC949D481D9F59C17D01E46EF9-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <DEPENDANT_MODULE_NAME><![CDATA[Core]]></DEPENDANT_MODULE_NAME>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.myob/src-test/org/openbravo/client/myob/test/MyOpenbravoTest.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.myob/src-test/org/openbravo/client/myob/test/MyOpenbravoTest.java	Wed Sep 03 16:32:14 2014 +0200
@@ -1,11 +1,31 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU 
+ * All portions are Copyright (C) 2014 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
 package org.openbravo.client.myob.test;
 
 import java.util.List;
 
+import org.junit.Test;
 import org.openbravo.client.myob.MyOpenbravoComponent;
-import org.openbravo.test.base.BaseTest;
+import org.openbravo.test.base.OBBaseTest;
 
-public class MyOpenbravoTest extends BaseTest {
+public class MyOpenbravoTest extends OBBaseTest {
   private static final String WIDGET_MOVED = "WIDGET_MOVED";
   private static final String WIDGET_ADDED = "WIDGET_ADDED";
   private static final String WIDGET_REMOVED = "WIDGET_REMOVED";
@@ -18,12 +38,7 @@
   protected static final String PARAMETERS = "parameters";
   private static final String DBINSTANCEID = "dbInstanceId";
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-
-  }
-
+  @Test
   public void testMyOpenbravoComponent() throws Exception {
     setTestAdminContext();
     final MyOpenbravoComponent component = new MyOpenbravoComponent();
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <NAME><![CDATA[Query/List Widget]]></NAME>
-<!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <VERSION><![CDATA[1.0.23921]]></VERSION>
+<!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <VERSION><![CDATA[1.0.24368]]></VERSION>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <DESCRIPTION><![CDATA[Provides the Query/List superclass widget that allows to create widget classes that prints a grid of data based on a query.]]></DESCRIPTION>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <HELP><![CDATA[With this module you can define your own widget classes that just with simple Application Dictionary shows a grid of data based on a HQL Query.]]></HELP>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <URL><![CDATA[http://forge.openbravo.com/projects/querylistwidget]]></URL>
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--26558497C31140BFAB067BA4BC47D799-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--26558497C31140BFAB067BA4BC47D799-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
 <!--26558497C31140BFAB067BA4BC47D799-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--26558497C31140BFAB067BA4BC47D799-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--26558497C31140BFAB067BA4BC47D799-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--26558497C31140BFAB067BA4BC47D799-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--26558497C31140BFAB067BA4BC47D799-->  <DEPENDANT_MODULE_NAME><![CDATA[My Openbravo Tab]]></DEPENDANT_MODULE_NAME>
 <!--26558497C31140BFAB067BA4BC47D799-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java	Wed Sep 03 16:32:14 2014 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2013 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -72,6 +73,7 @@
 import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.datasource.DataSourceProperty;
 import org.openbravo.service.datasource.ReadOnlyDataSourceService;
+import org.openbravo.service.json.AdvancedQueryBuilder;
 import org.openbravo.service.json.JsonConstants;
 import org.openbravo.service.json.JsonUtils;
 
@@ -83,6 +85,7 @@
 public class QueryListDataSource extends ReadOnlyDataSourceService implements PortalAccessible {
   private static final String OPTIONAL_FILTERS = "@optional_filters@";
   private static final Logger log = Logger.getLogger(QueryListDataSource.class);
+  private static final String OPERATOR = "$OPERATOR";
 
   /**
    * Returns the count of objects based on the passed parameters.
@@ -151,6 +154,8 @@
         for (int i = 0; i < criterias.length(); i++) {
           final JSONObject criteria = criterias.getJSONObject(i);
           parameters.put(criteria.getString("fieldName"), criteria.getString("value"));
+          parameters
+              .put(criteria.getString("fieldName") + OPERATOR, criteria.getString("operator"));
         }
       } catch (JSONException e) {
         // Ignore exception.
@@ -160,6 +165,16 @@
       // Parse the HQL in case that optional filters are required
       HQL = parseOptionalFilters(HQL, viewMode, parameters, columns, xmlDateFormat);
 
+      if (parameters.containsKey(JsonConstants.SUMMARY_PARAMETER)) {
+        // if the request comes from the summary row, update the select clause so that it obtains
+        // the values for the summary fields
+        HQL = updateHQLWithSummaryFields(HQL, parameters.get(JsonConstants.SUMMARY_PARAMETER));
+      }
+
+      if (parameters.containsKey(JsonConstants.SORTBY_PARAMETER)) {
+        HQL = updateSortByFields(HQL, parameters.get(JsonConstants.SORTBY_PARAMETER));
+      }
+
       Query widgetQuery = OBDal.getInstance().getSession().createQuery(HQL);
       String[] queryAliases = widgetQuery.getReturnAliases();
 
@@ -204,51 +219,77 @@
       }
 
       final List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
-      for (Object objResult : widgetQuery.list()) {
-        final Map<String, Object> data = new LinkedHashMap<String, Object>();
-        Object[] resultList = new Object[1];
-        if (objResult instanceof Object[]) {
-          resultList = (Object[]) objResult;
-        } else {
-          resultList[0] = objResult;
+
+      if (parameters.containsKey(JsonConstants.SUMMARY_PARAMETER)) {
+        // process the response for the summary row
+        Map<String, Object> summaryData = new LinkedHashMap<String, Object>();
+        try {
+          JSONObject summaryFieldsObject = new JSONObject(
+              parameters.get(JsonConstants.SUMMARY_PARAMETER));
+          Iterator<?> summaryFieldNameIterator = summaryFieldsObject.keys();
+          Object uniqueResult = widgetQuery.uniqueResult();
+          if (uniqueResult instanceof Object[]) {
+            // handles the case where the values of several summary fields are request
+            Object[] summaryValues = (Object[]) uniqueResult;
+            int i = 0;
+            while (summaryFieldNameIterator.hasNext()) {
+              String summaryFieldName = (String) summaryFieldNameIterator.next();
+              summaryData.put(summaryFieldName, summaryValues[i++]);
+            }
+          } else {
+            // handles the case where the value of just one summary field is request
+            String summaryFieldName = (String) summaryFieldsObject.names().get(0);
+            summaryData.put(summaryFieldName, uniqueResult);
+          }
+          summaryData.put("isGridSummary", true);
+        } catch (Exception e) {
         }
+        result.add(summaryData);
 
-        for (OBCQL_QueryColumn column : columns) {
-          UIDefinition uiDefinition = UIDefinitionController.getInstance().getUIDefinition(
-              column.getReference());
-          DomainType domainType = uiDefinition.getDomainType();
-          // TODO: throw an exception if the display expression doesn't match any returned alias.
-          for (int i = 0; i < queryAliases.length; i++) {
-            if (queryAliases[i].equals(column.getDisplayExpression())
-                || (!isExport && queryAliases[i].equals(column.getLinkExpression()))) {
-              Object value = resultList[i];
-              if (value instanceof Timestamp) {
-                value = xmlDateTimeFormat.format(value);
-                value = JsonUtils.convertToCorrectXSDFormat((String) value);
-              }
-              if (value instanceof Date) {
-                value = xmlDateFormat.format(value);
-              }
+      } else {
+        // process the response for the grid
+        for (Object objResult : widgetQuery.list()) {
+          final Map<String, Object> data = new LinkedHashMap<String, Object>();
+          Object[] resultList = new Object[1];
+          if (objResult instanceof Object[]) {
+            resultList = (Object[]) objResult;
+          } else {
+            resultList[0] = objResult;
+          }
 
-              if (domainType instanceof BooleanDomainType) {
-                if (value instanceof String) {
-                  value = ((PrimitiveDomainType) domainType).createFromString((String) value);
+          for (OBCQL_QueryColumn column : columns) {
+            UIDefinition uiDefinition = UIDefinitionController.getInstance().getUIDefinition(
+                column.getReference());
+            DomainType domainType = uiDefinition.getDomainType();
+            // TODO: throw an exception if the display expression doesn't match any returned alias.
+            for (int i = 0; i < queryAliases.length; i++) {
+              if (queryAliases[i].equals(column.getDisplayExpression())
+                  || (!isExport && queryAliases[i].equals(column.getLinkExpression()))) {
+                Object value = resultList[i];
+                if (domainType instanceof DateDomainType || domainType instanceof DateDomainType) {
+                    value = xmlDateFormat.format(value);
+                  }
+                else if (value instanceof Timestamp) {
+                  value = xmlDateTimeFormat.format(value);
+                  value = JsonUtils.convertToCorrectXSDFormat((String) value);
                 }
-              }
 
-              if (!isExport) {
-                data.put(queryAliases[i], value);
-              } else {
-                data.put(QueryListUtils.getColumnLabel(column), value);
+                if (domainType instanceof BooleanDomainType) {
+                  if (value instanceof String) {
+                    value = ((PrimitiveDomainType) domainType).createFromString((String) value);
+                  }
+                }
+
+                if (!isExport) {
+                  data.put(queryAliases[i], value);
+                } else {
+                  data.put(QueryListUtils.getColumnLabel(column), value);
+                }
               }
             }
           }
+          result.add(data);
         }
-        result.add(data);
-      }
-      String sortBy = parameters.get("_sortBy");
-      if (StringUtils.isNotEmpty(sortBy)) {
-        sort(sortBy, result);
       }
       return result;
     } finally {
@@ -256,7 +297,126 @@
     }
   }
 
-  // Checks if the widget is embedded in a tab accessible by the user
+  /**
+   * Updates the order by clause of the HQL query so that it obtains the values for the summary
+   * fields. If the HQL query already contains order by fields, the new fields are appended for the
+   * existing fields.
+   * 
+   * @param hQL
+   *          original HQL query
+   * @param sortByParametersString
+   *          parameter that contains sortBy field values
+   * @return an updated HQL query that will set the order by fields
+   */
+  private String updateSortByFields(String hql, String sortBy) {
+    String[] fieldList = null;
+    String sortByClause = "", hqlString = hql;
+    if (sortBy.contains(",")) {
+      fieldList = sortBy.split(",");
+    }
+    if (hqlString.toLowerCase().contains("order by")) {
+      if (fieldList == null) {
+        sortByClause = sortBy.startsWith("-") ? sortBy.substring(1, sortBy.length()) + " desc "
+            : sortBy;
+      } else {
+        // sort by multiple columns
+        for (String field : fieldList) {
+          sortByClause = field.startsWith("-") ? sortByClause.concat(field.substring(1,
+              field.length()))
+              + " desc " : sortByClause.concat(field);
+        }
+      }
+      int sortByIndex = hqlString.toLowerCase().indexOf("order by");
+      hqlString = hqlString.substring(0, sortByIndex + "order by".length() + 1) + sortByClause
+          + "," + hqlString.substring(sortByIndex + "order by".length() + 1);
+    } else {
+      hqlString = hqlString.concat(" order by " + sortByClause);
+    }
+    return hqlString;
+  }
+
+  /**
+   * Updates the select clause of the HQL query so that it obtains the values for the summary fields
+   * 
+   * @param hQL
+   *          original HQL query
+   * @param summaryParametersString
+   *          parameter that contains pairs of summaryField - summaryFunction values
+   * @return an updated HQL query that will obtain the values for the summary fields
+   */
+  private String updateHQLWithSummaryFields(String hQL, String summaryParametersString) {
+    // get rid of the original select clause, a new one is going to be built
+    String updatedHQL = removeSelectClause(hQL);
+    // the order clause is not needed when obtaining the values for the summary fields
+    updatedHQL = removeOrderByClause(updatedHQL);
+    try {
+      JSONObject summaryFieldsObject = new JSONObject(summaryParametersString);
+      Iterator<?> summaryFieldNameIterator = summaryFieldsObject.keys();
+      StringBuilder selectClause = new StringBuilder("select ");
+      boolean first = true;
+      while (summaryFieldNameIterator.hasNext()) {
+        String summaryFieldName = (String) summaryFieldNameIterator.next();
+        String summaryFunction = summaryFieldsObject.getString(summaryFieldName);
+        if (!first) {
+          selectClause.append(", ");
+        } else {
+          first = false;
+        }
+        // only three summary functions are available for the columns of Query/List widgets: count,
+        // sum and avg
+        if ("count".equals(summaryFunction)) {
+          selectClause.append("count(*)");
+        } else if ("sum".equals(summaryFunction)) {
+          selectClause.append("sum(" + summaryFieldName + ")");
+        } else if ("avg".equals(summaryFunction)) {
+          selectClause.append("sum(" + summaryFieldName + ")/count(*)");
+        }
+      }
+      updatedHQL = selectClause.toString() + " " + updatedHQL;
+    } catch (JSONException e) {
+      log.error("Error obtaining the values of the summary fields", e);
+    }
+    return updatedHQL;
+  }
+
+  /**
+   * Removes the select clause of a hql query
+   * 
+   * @param hql
+   *          the original hql query
+   * @return the original hql query without its select clause
+   */
+  private String removeSelectClause(String hql) {
+    String hqlWithoutSelectClause = hql;
+    if (hqlWithoutSelectClause.toLowerCase().indexOf(" from ") != -1) {
+      hqlWithoutSelectClause = hqlWithoutSelectClause.substring(hqlWithoutSelectClause
+          .toLowerCase().indexOf(" from "));
+    } else if (hqlWithoutSelectClause.toLowerCase().indexOf("\nfrom ") != -1) {
+      hqlWithoutSelectClause = hqlWithoutSelectClause.substring(hqlWithoutSelectClause
+          .toLowerCase().indexOf("\nfrom "));
+    }
+    return hqlWithoutSelectClause;
+  }
+
+  /**
+   * Removes the order by clause of a hql query
+   * 
+   * @param hql
+   *          the original hql query
+   * @return the original hql query without its select clause
+   */
+  private String removeOrderByClause(String hql) {
+    String hqlWithoutOrderByClause = hql;
+    if (hqlWithoutOrderByClause.toLowerCase().indexOf(" order by ") != -1) {
+      hqlWithoutOrderByClause = hqlWithoutOrderByClause.substring(0, hqlWithoutOrderByClause
+          .toLowerCase().indexOf(" order by "));
+    } else if (hqlWithoutOrderByClause.toLowerCase().indexOf("\norder by ") != -1) {
+      hqlWithoutOrderByClause = hqlWithoutOrderByClause.substring(0, hqlWithoutOrderByClause
+          .toLowerCase().indexOf("\norder by "));
+    }
+    return hqlWithoutOrderByClause;
+  } // Checks if the widget is embedded in a tab accessible by the user
+
   private boolean isAccessibleWidgetInForm(WidgetClass widgetClass) {
     OBCriteria<WidgetReference> widgetInFormCriteria = OBDal.getInstance().createCriteria(
         WidgetReference.class);
@@ -371,6 +531,7 @@
       for (OBCQL_QueryColumn column : columns) {
         if (column.isCanBeFiltered()) {
           String value = parameters.get(column.getDisplayExpression());
+          String operator = parameters.get(column.getDisplayExpression() + OPERATOR);
           if (column.getReference().getName().equals("YesNo") && value != null) {
             if (value.equals("true")) {
               value = "Y";
@@ -380,7 +541,7 @@
           }
           String whereClause = " 1=1 ";
           if (value != null) {
-            whereClause = getWhereClause(value, column, xmlDateFormat);
+            whereClause = getWhereClause(value, column, xmlDateFormat, operator);
           }
 
           if (HQL.contains("@" + column.getDisplayExpression() + "@")) {
@@ -396,13 +557,18 @@
   }
 
   private String getWhereClause(String value, OBCQL_QueryColumn column,
-      SimpleDateFormat xmlDateFormat) {
+      SimpleDateFormat xmlDateFormat, String operator) {
     String whereClause = "";
     DomainType domainType = ModelProvider.getInstance().getReference(column.getReference().getId())
         .getDomainType();
     if (domainType.getClass().getSuperclass().equals(BigDecimalDomainType.class)
         || domainType.getClass().equals(LongDomainType.class)) {
-      whereClause = column.getWhereClauseLeftPart() + " = " + value;
+      if (StringUtils.isNotEmpty(value)) {
+        whereClause = column.getWhereClauseLeftPart() + " "
+            + AdvancedQueryBuilder.getHqlOperator(operator) + " " + value;
+      } else {
+        whereClause = " 1=1 ";
+      }
     } else if (domainType.getClass().equals(DateDomainType.class)) {
       try {
         final Calendar cal = Calendar.getInstance();
--- a/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Wed Sep 03 16:32:14 2014 +0200
@@ -345,5 +345,36 @@
     } else {
       this.widget.setTotalRows(dsResponse.totalRows);
     }
+  },
+
+  // the next three functions allow to support obtaining the values of the summary fields from the server
+  getSummaryRowDataSource: function () {
+    if (this.getSummarySettings()) {
+      return this.getDataSource();
+    }
+  },
+
+  getSummaryRowFetchRequestConfig: function () {
+    var fld, i, summary = this.getSummarySettings(),
+        config = this.Super('getSummaryRowFetchRequestConfig', arguments);
+    if (summary) {
+      config.params = config.params || {};
+      config.params._summary = summary;
+      config.params = this.getFetchRequestParams(config.params);
+    }
+    return config;
+  },
+
+  getSummarySettings: function () {
+    var fld, i, summary;
+
+    for (i = 0; i < this.getFields().length; i++) {
+      fld = this.getFields()[i];
+      if (fld.summaryFunction && isc.OBViewGrid.SUPPORTED_SUMMARY_FUNCTIONS.contains(fld.summaryFunction)) {
+        summary = summary || {};
+        summary[fld.displayField || fld.name] = fld.summaryFunction;
+      }
+    }
+    return summary;
   }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--FF8080812D842086012D844F3CC0003E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--FF8080812D842086012D844F3CC0003E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080812D842086012D844F3CC0003E-->  <NAME><![CDATA[Widgets Collection]]></NAME>
-<!--FF8080812D842086012D844F3CC0003E-->  <VERSION><![CDATA[0.0.23921]]></VERSION>
+<!--FF8080812D842086012D844F3CC0003E-->  <VERSION><![CDATA[0.0.24368]]></VERSION>
 <!--FF8080812D842086012D844F3CC0003E-->  <DESCRIPTION><![CDATA[Collection of Workspace Widgets]]></DESCRIPTION>
 <!--FF8080812D842086012D844F3CC0003E-->  <HELP><![CDATA[Collection of Workspace Widgets]]></HELP>
 <!--FF8080812D842086012D844F3CC0003E-->  <URL><![CDATA[http://forge.openbravo.com/projects/widgetscollection]]></URL>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--FF8080812D842086012D845002070046-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080812D842086012D845002070046-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
 <!--FF8080812D842086012D845002070046-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--FF8080812D842086012D845002070046-->  <STARTVERSION><![CDATA[2.1.23921]]></STARTVERSION>
+<!--FF8080812D842086012D845002070046-->  <STARTVERSION><![CDATA[2.1.24368]]></STARTVERSION>
 <!--FF8080812D842086012D845002070046-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--FF8080812D842086012D845002070046-->  <DEPENDANT_MODULE_NAME><![CDATA[Workspace & Widgets]]></DEPENDANT_MODULE_NAME>
 <!--FF8080812D842086012D845002070046-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -36,6 +36,18 @@
 <!--3E4B6571585941E0A8A512AF05C6FEFB-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--3E4B6571585941E0A8A512AF05C6FEFB--></AD_MESSAGE>
 
+<!--539E13EEA53444C9BB7A4C97E78D38D0--><AD_MESSAGE>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <AD_MESSAGE_ID><![CDATA[539E13EEA53444C9BB7A4C97E78D38D0]]></AD_MESSAGE_ID>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <VALUE><![CDATA[FINPR_TooManyRecords]]></VALUE>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <MSGTEXT><![CDATA[Too many records for an HTML search. Please export to Excel or PDF instead.]]></MSGTEXT>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <AD_MODULE_ID><![CDATA[2A5EE903D7974AC298C0504FBC4501A7]]></AD_MODULE_ID>
+<!--539E13EEA53444C9BB7A4C97E78D38D0-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--539E13EEA53444C9BB7A4C97E78D38D0--></AD_MESSAGE>
+
 <!--5DD299179EC64419B6B1EDD29DB2E777--><AD_MESSAGE>
 <!--5DD299179EC64419B6B1EDD29DB2E777-->  <AD_MESSAGE_ID><![CDATA[5DD299179EC64419B6B1EDD29DB2E777]]></AD_MESSAGE_ID>
 <!--5DD299179EC64419B6B1EDD29DB2E777-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <NAME><![CDATA[Payment Report]]></NAME>
-<!--2A5EE903D7974AC298C0504FBC4501A7-->  <VERSION><![CDATA[3.0.23921]]></VERSION>
+<!--2A5EE903D7974AC298C0504FBC4501A7-->  <VERSION><![CDATA[3.0.24368]]></VERSION>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <DESCRIPTION><![CDATA[Payment Report]]></DESCRIPTION>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <URL><![CDATA[http://forge.openbravo.com/projects/paymentreport]]></URL>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <TYPE><![CDATA[M]]></TYPE>
--- a/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <AD_MODULE_ID><![CDATA[2A5EE903D7974AC298C0504FBC4501A7]]></AD_MODULE_ID>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_DEPENDENT_MODULE_ID>
-<!--A3B449C4D5FE4D688CC58236FE33B802-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--A3B449C4D5FE4D688CC58236FE33B802-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <DEPENDANT_MODULE_NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></DEPENDANT_MODULE_NAME>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReport.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReport.java	Wed Sep 03 16:32:14 2014 +0200
@@ -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) 2009-2012 Openbravo SL 
+ * All portions are Copyright (C) 2009-2014 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -332,7 +332,7 @@
             strPaymentMethodId, strFinancialAccountId, strcCurrency, strConvertCurrency,
             strConversionDate, strPaymType, strOverdue, strGroupCrit, strOrdCrit,
             strInclPaymentUsingCredit, strPaymentDateFrom, strPaymentDateTo, strExpectedDateFrom,
-            strExpectedDateTo);
+            strExpectedDateTo, "HTML");
       } catch (OBException e) {
         discardAL.add("sectionGroupCrit");
         discardAL.add("sectionStatus");
@@ -348,11 +348,12 @@
         xmlDocument.setParameter("messageType", "WARNING");
         xmlDocument.setParameter("messageTitle",
             Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()));
-        xmlDocument
-            .setParameter(
-                "messageMessage",
-                Utility.messageBD(this, "FINPR_NoConversionFound", vars.getLanguage())
-                    + e.getMessage());
+        String noConversionFound = "";
+        if (e.getMessage() != null && e.getMessage().contains("->"))
+          noConversionFound = Utility
+              .messageBD(this, "FINPR_NoConversionFound", vars.getLanguage());
+        xmlDocument.setParameter("messageMessage",
+            noConversionFound + Utility.messageBD(this, e.getMessage(), vars.getLanguage()));
       }
 
       if (data != null && data.length == 0) {
@@ -765,7 +766,7 @@
           strPaymentMethodId, strFinancialAccountId, strcCurrency, strConvertCurrency,
           strConversionDate, strPaymType, strOverdue, strGroupCrit, strOrdCrit,
           strInclPaymentUsingCredit, strPaymentDateFrom, strPaymentDateTo, strExpectedDateFrom,
-          strExpectedDateTo);
+          strExpectedDateTo, strOutput);
     } catch (OBException e) {
       advisePopUp(request, response, "WARNING",
           Utility.messageBD(this, "ProcessStatus-W", vars.getLanguage()),
--- a/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Wed Sep 03 16:32:14 2014 +0200
@@ -32,7 +32,10 @@
 
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.log4j.Logger;
+import org.hibernate.LockOptions;
 import org.hibernate.Query;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
 import org.hibernate.Session;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
@@ -177,6 +180,8 @@
     }
   }
 
+  @Deprecated
+  // Deprecated when adding output format to check number of lines allowed
   public FieldProvider[] getPaymentReport(VariablesSecureApp vars, String strOrg,
       String strInclSubOrg, String strDueDateFrom, String strDueDateTo, String strAmountFrom,
       String strAmountTo, String strDocumentDateFrom, String strDocumentDateTo,
@@ -187,31 +192,42 @@
       String strOrdCrit, String strInclPaymentUsingCredit, String strPaymentDateFrom,
       String strPaymentDateTo, String strExpectedDateFrom, String strExpectedDateTo)
       throws OBException {
+    return getPaymentReport(vars, strOrg, strInclSubOrg, strDueDateFrom, strDueDateTo,
+        strAmountFrom, strAmountTo, strDocumentDateFrom, strDocumentDateTo, strcBPartnerIdIN,
+        strcBPGroupIdIN, strcNoBusinessPartner, strcProjectIdIN, strfinPaymSt, strPaymentMethodId,
+        strFinancialAccountId, strcCurrency, strConvertCurrency, strConversionDate, strPaymType,
+        strOverdue, strGroupCrit, strOrdCrit, strInclPaymentUsingCredit, strPaymentDateFrom,
+        strPaymentDateTo, strExpectedDateFrom, strExpectedDateTo, "dummy");
+  }
 
-    final StringBuilder hsqlScript = new StringBuilder();
+  FieldProvider[] getPaymentReport(VariablesSecureApp vars, String strOrg, String strInclSubOrg,
+      String strDueDateFrom, String strDueDateTo, String strAmountFrom, String strAmountTo,
+      String strDocumentDateFrom, String strDocumentDateTo, String strcBPartnerIdIN,
+      String strcBPGroupIdIN, String strcNoBusinessPartner, String strcProjectIdIN,
+      String strfinPaymSt, String strPaymentMethodId, String strFinancialAccountId,
+      String strcCurrency, String strConvertCurrency, String strConversionDate, String strPaymType,
+      String strOverdue, String strGroupCrit, String strOrdCrit, String strInclPaymentUsingCredit,
+      String strPaymentDateFrom, String strPaymentDateTo, String strExpectedDateFrom,
+      String strExpectedDateTo, String strOutput) throws OBException {
+
+    StringBuilder hsqlScript = new StringBuilder();
     final java.util.List<Object> parameters = new ArrayList<Object>();
 
     String dateFormatString = OBPropertiesProvider.getInstance().getOpenbravoProperties()
         .getProperty("dateFormat.java");
     SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString);
-    FieldProvider[] data;
-    FieldProvider[] transactionData;
     Currency transCurrency;
     BigDecimal transAmount = null;
     ConversionRate convRate = null;
-    ArrayList<FieldProvider> groupedData = new ArrayList<FieldProvider>();
     ArrayList<FieldProvider> totalData = new ArrayList<FieldProvider>();
     int numberOfElements = 0;
     int lastElement = 0;
     boolean existsConvRate = false;
+    ScrollableResults scroller = null;
 
     OBContext.setAdminMode(true);
     try {
 
-      hsqlScript
-          .append("select fpsd.id, (select a.sequenceNumber from ADList a where a.reference.id = '575BCB88A4694C27BC013DE9C73E6FE7' and a.searchKey = coalesce(pay.status, 'RPAP')) as a,");
-      hsqlScript
-          .append(" (select trans.id from FIN_Finacc_Transaction trans left outer join trans.finPayment payment where payment.id=pay.id) as trans ");
       hsqlScript.append(" from FIN_Payment_ScheduleDetail as fpsd ");
       hsqlScript.append(" left outer join fpsd.paymentDetails.finPayment pay");
       hsqlScript.append(" left outer join pay.businessPartner paybp");
@@ -499,6 +515,31 @@
         parameters.add(DateUtils.truncate(new Date(), Calendar.DATE));
       }
 
+      if ("HTML".equals(strOutput)) {
+        int maxRecords = 1000;
+        final Session sessionCount = OBDal.getInstance().getSession();
+        final Query queryCount = sessionCount
+            .createQuery("select count(*)" + hsqlScript.toString());
+        int px = 0;
+        for (final Object param : parameters) {
+          if (param instanceof BaseOBObject) {
+            queryCount.setEntity(px++, param);
+          } else {
+            queryCount.setParameter(px++, param);
+          }
+        }
+        final Long hqlRecordsCount = (Long) queryCount.list().get(0);
+        if ((int) (long) hqlRecordsCount > maxRecords) {
+          String message = "FINPR_TooManyRecords";
+          throw new OBException(message);
+        }
+      }
+
+      final StringBuilder firstLineQuery = new StringBuilder();
+      firstLineQuery
+          .append("select fpsd, (select a.sequenceNumber from ADList a where a.reference.id = '575BCB88A4694C27BC013DE9C73E6FE7' and a.searchKey = coalesce(pay.status, 'RPAP')) as a");
+      hsqlScript = firstLineQuery.append(hsqlScript);
+
       hsqlScript.append(" order by ");
 
       if (strGroupCrit.equalsIgnoreCase("APRM_FATS_BPARTNER")) {
@@ -606,33 +647,7 @@
         }
       }
 
-      HashMap<String, FIN_FinaccTransaction> hashMapTransactions = new HashMap<String, FIN_FinaccTransaction>();
-      int index = 0;
-      java.util.List<FIN_PaymentScheduleDetail> obqPSDList = new ArrayList<FIN_PaymentScheduleDetail>();
-      for (Object resultObject : query.list()) {
-        if (resultObject.getClass().isArray()) {
-          final Object[] values = (Object[]) resultObject;
-          String StringPSDId = "";
-          for (Object value : values) {
-            if (index == 0) {
-              obqPSDList.add(OBDal.getInstance().get(FIN_PaymentScheduleDetail.class,
-                  (String) value));
-              StringPSDId = (String) value;
-            } else if (index == 2) {
-              if (value != null) {
-                hashMapTransactions.put(StringPSDId,
-                    OBDal.getInstance().get(FIN_FinaccTransaction.class, value));
-              }
-              index = -1;// firstMember = true;
-            }
-            index++;
-          }
-        }
-      }
-      data = FieldProviderFactory.getFieldProviderArray(obqPSDList);
-
-      FIN_PaymentScheduleDetail[] FIN_PaymentScheduleDetail = new FIN_PaymentScheduleDetail[0];
-      FIN_PaymentScheduleDetail = obqPSDList.toArray(FIN_PaymentScheduleDetail);
+      scroller = query.scroll(ScrollMode.FORWARD_ONLY);
 
       FIN_PaymentDetail finPaymDetail;
       Boolean mustGroup;
@@ -641,6 +656,7 @@
       BigDecimal amountSum = BigDecimal.ZERO;
       BigDecimal balanceSum = BigDecimal.ZERO;
       FieldProvider previousRow = null;
+      FieldProvider lastGroupedDatarow = null;
       ConversionRate previousConvRate = null;
       boolean isReceipt = false;
       boolean isAmtInLimit = false;
@@ -653,138 +669,160 @@
           strcNoBusinessPartner, strDueDateFrom, strDueDateTo, strExpectedDateFrom,
           strExpectedDateTo);
 
-      transactionData = FieldProviderFactory.getFieldProviderArray(transactionsList);
-      int totalTransElements = transactionsList.size();
-
       // There are three variables involved in this loop. The first one is data, wich is the
       // the one the loop processes. Then grouped data is used to group similar data lines into
       // one. Finally total data adds the remaining information that is not in data.
-      for (int i = 0; i < data.length; i++) {
+      int i = 0;
+      while (scroller.next()) {
+        i++;
+        // get 1st column (idx=0)
+        Object value = scroller.get(0);
 
+        // TODO: rename variable to not have same name as class
+        FIN_PaymentScheduleDetail FIN_PaymentScheduleDetail = (FIN_PaymentScheduleDetail) value;
+
+        // make a empty FieldProvider instead of saving link to DAL-object
+        FieldProvider data = FieldProviderFactory.getFieldProvider(null);
+
+        if (i % 100 == 0) {
+          OBDal.getInstance().getSession().clear();
+        }
+        OBDal.getInstance().getSession().buildLockRequest(LockOptions.NONE)
+            .lock(FIN_PaymentScheduleDetail.ENTITY_NAME, FIN_PaymentScheduleDetail);
+
+        // search for fin_finacc_transaction for this payment
+        FIN_FinaccTransaction trx = null;
+        FIN_PaymentDetail detail = FIN_PaymentScheduleDetail.getPaymentDetails();
+        if (detail != null) {
+          OBCriteria<FIN_FinaccTransaction> trxQuery = OBDal.getInstance().createCriteria(
+              FIN_FinaccTransaction.class);
+          trxQuery.add(Restrictions.eq(FIN_FinaccTransaction.PROPERTY_FINPAYMENT,
+              detail.getFinPayment()));
+          // uniqueness guaranteed via unique constraint in db
+          trx = (FIN_FinaccTransaction) trxQuery.uniqueResult();
+        }
         // If the payment schedule detail has a payment detail, then, the information is taken from
         // the payment. If not, the information is taken from the invoice (the else).
-        if (FIN_PaymentScheduleDetail[i].getPaymentDetails() != null) {
-          BusinessPartner bp = getDocumentBusinessPartner(FIN_PaymentScheduleDetail[i]);
+        if (FIN_PaymentScheduleDetail.getPaymentDetails() != null) {
+          BusinessPartner bp = getDocumentBusinessPartner(FIN_PaymentScheduleDetail);
           if (bp == null) {
-            FieldProviderFactory.setField(data[i], "BP_GROUP", "");
-            FieldProviderFactory.setField(data[i], "BPARTNER", "");
+            FieldProviderFactory.setField(data, "BP_GROUP", "");
+            FieldProviderFactory.setField(data, "BPARTNER", "");
           } else {
             // bp_group -- bp_category
-            FieldProviderFactory.setField(data[i], "BP_GROUP", bp.getBusinessPartnerCategory()
+            FieldProviderFactory.setField(data, "BP_GROUP", bp.getBusinessPartnerCategory()
                 .getName());
             // bpartner
-            FieldProviderFactory.setField(data[i], "BPARTNER", bp.getName());
+            FieldProviderFactory.setField(data, "BPARTNER", bp.getName());
           }
 
           // transCurrency
-          transCurrency = FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
+          transCurrency = FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
               .getCurrency();
-          FieldProviderFactory.setField(data[i], "TRANS_CURRENCY", transCurrency.getISOCode());
+          FieldProviderFactory.setField(data, "TRANS_CURRENCY", transCurrency.getISOCode());
           // paymentMethod
-          FieldProviderFactory.setField(data[i], "PAYMENT_METHOD", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "PAYMENT_METHOD", FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment().getPaymentMethod().getIdentifier());
 
           // payment
           FieldProviderFactory
               .setField(
-                  data[i],
+                  data,
                   "PAYMENT",
-                  ((FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                      .getPaymentDate() != null) ? dateFormat.format(FIN_PaymentScheduleDetail[i]
-                      .getPaymentDetails().getFinPayment().getPaymentDate()) : "Null")
+                  ((FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().getPaymentDate() != null) ? dateFormat
+                      .format(FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
+                          .getPaymentDate()) : "Null")
                       + " - "
-                      + FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
+                      + FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
                           .getDocumentNo());
           // payment description
-          FieldProviderFactory.setField(data[i], "PAYMENT_DESC", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "PAYMENT_DESC", FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment().getDescription());
           // payment_id
-          FieldProviderFactory.setField(data[i], "PAYMENT_ID", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "PAYMENT_ID", FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment().getId().toString());
           // payment_date
           FieldProviderFactory
               .setField(
-                  data[i],
+                  data,
                   "PAYMENT_DATE",
-                  (FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                      .getPaymentDate() != null) ? dateFormat.format(FIN_PaymentScheduleDetail[i]
-                      .getPaymentDetails().getFinPayment().getPaymentDate()) : "Null");
+                  (FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().getPaymentDate() != null) ? dateFormat
+                      .format(FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
+                          .getPaymentDate()) : "Null");
           // payment_docNo
-          FieldProviderFactory.setField(data[i], "PAYMENT_DOCNO", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "PAYMENT_DOCNO", FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment().getDocumentNo());
           // payment yes / no
-          FieldProviderFactory.setField(data[i], "PAYMENT_Y_N", "");
+          FieldProviderFactory.setField(data, "PAYMENT_Y_N", "");
           // financialAccount
-          FieldProviderFactory.setField(data[i], "FINANCIAL_ACCOUNT",
-              FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                  .getFINFinaccTransactionList().size() != 0 ? FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "FINANCIAL_ACCOUNT",
+              FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
+                  .getFINFinaccTransactionList().size() != 0 ? FIN_PaymentScheduleDetail
                   .getPaymentDetails().getFinPayment().getFINFinaccTransactionList().get(0)
-                  .getAccount().getName() : FIN_PaymentScheduleDetail[i].getPaymentDetails()
+                  .getAccount().getName() : FIN_PaymentScheduleDetail.getPaymentDetails()
                   .getFinPayment().getAccount().getName());
           // status
-          FieldProviderFactory.setField(data[i], "STATUS",
-              translateRefList(FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                  .getStatus()));
-          FieldProviderFactory.setField(data[i], "STATUS_CODE", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "STATUS", translateRefList(FIN_PaymentScheduleDetail
+              .getPaymentDetails().getFinPayment().getStatus()));
+          FieldProviderFactory.setField(data, "STATUS_CODE", FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment().getStatus());
           // is receipt
-          if (FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment().isReceipt()) {
-            FieldProviderFactory.setField(data[i], "ISRECEIPT", "Y");
+          if (FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().isReceipt()) {
+            FieldProviderFactory.setField(data, "ISRECEIPT", "Y");
             isReceipt = true;
           } else {
-            FieldProviderFactory.setField(data[i], "ISRECEIPT", "N");
+            FieldProviderFactory.setField(data, "ISRECEIPT", "N");
             isReceipt = false;
           }
           // deposit/withdraw date
-          if (hashMapTransactions.containsKey(FIN_PaymentScheduleDetail[i].getId().toString())) {
-            FieldProviderFactory.setField(data[i], "DEPOSIT_WITHDRAW_DATE", dateFormat
-                .format(hashMapTransactions.get(FIN_PaymentScheduleDetail[i].getId())
-                    .getTransactionDate()));
+          if (trx != null) {
+            FieldProviderFactory.setField(data, "DEPOSIT_WITHDRAW_DATE",
+                dateFormat.format(trx.getTransactionDate()));
           } else {
-            FieldProviderFactory.setField(data[i], "DEPOSIT_WITHDRAW_DATE", "");
+            FieldProviderFactory.setField(data, "DEPOSIT_WITHDRAW_DATE", "");
           }
         } else {
 
           // bp_group -- bp_category
-          FieldProviderFactory.setField(data[i], "BP_GROUP", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "BP_GROUP", FIN_PaymentScheduleDetail
               .getInvoicePaymentSchedule().getInvoice().getBusinessPartner()
               .getBusinessPartnerCategory().getName());
           // bpartner
-          FieldProviderFactory.setField(data[i], "BPARTNER", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "BPARTNER", FIN_PaymentScheduleDetail
               .getInvoicePaymentSchedule().getInvoice().getBusinessPartner().getName());
           // transCurrency
-          transCurrency = FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getInvoice()
+          transCurrency = FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getInvoice()
               .getCurrency();
-          FieldProviderFactory.setField(data[i], "TRANS_CURRENCY", transCurrency.getISOCode());
+          FieldProviderFactory.setField(data, "TRANS_CURRENCY", transCurrency.getISOCode());
           // paymentMethod
-          FieldProviderFactory.setField(data[i], "PAYMENT_METHOD", FIN_PaymentScheduleDetail[i]
+          FieldProviderFactory.setField(data, "PAYMENT_METHOD", FIN_PaymentScheduleDetail
               .getInvoicePaymentSchedule().getFinPaymentmethod().getIdentifier());
           // payment
-          FieldProviderFactory.setField(data[i], "PAYMENT", "");
+          FieldProviderFactory.setField(data, "PAYMENT", "");
           // payment_id
-          FieldProviderFactory.setField(data[i], "PAYMENT_ID", "");
+          FieldProviderFactory.setField(data, "PAYMENT_ID", "");
           // payment_date
-          FieldProviderFactory.setField(data[i], "PAYMENT_DATE", "");
+          FieldProviderFactory.setField(data, "PAYMENT_DATE", "");
           // payment_docNo
-          FieldProviderFactory.setField(data[i], "PAYMENT_DOCNO", "");
+          FieldProviderFactory.setField(data, "PAYMENT_DOCNO", "");
           // payment yes / no
-          FieldProviderFactory.setField(data[i], "PAYMENT_Y_N", "Display:None");
+          FieldProviderFactory.setField(data, "PAYMENT_Y_N", "Display:None");
           // financialAccount
-          FieldProviderFactory.setField(data[i], "FINANCIAL_ACCOUNT", "");
+          FieldProviderFactory.setField(data, "FINANCIAL_ACCOUNT", "");
           // status
-          FieldProviderFactory.setField(data[i], "STATUS", translateRefList("RPAP"));
-          FieldProviderFactory.setField(data[i], "STATUS_CODE", "RPAP");
+          FieldProviderFactory.setField(data, "STATUS", translateRefList("RPAP"));
+          FieldProviderFactory.setField(data, "STATUS_CODE", "RPAP");
           // is receipt
-          if (FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getInvoice()
+          if (FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getInvoice()
               .isSalesTransaction()) {
-            FieldProviderFactory.setField(data[i], "ISRECEIPT", "Y");
+            FieldProviderFactory.setField(data, "ISRECEIPT", "Y");
             isReceipt = true;
           } else {
-            FieldProviderFactory.setField(data[i], "ISRECEIPT", "N");
+            FieldProviderFactory.setField(data, "ISRECEIPT", "N");
             isReceipt = false;
           }
           // deposit/withdraw date
-          FieldProviderFactory.setField(data[i], "DEPOSIT_WITHDRAW_DATE", "");
+          FieldProviderFactory.setField(data, "DEPOSIT_WITHDRAW_DATE", "");
         }
 
         /*
@@ -797,75 +835,75 @@
          * 
          * - Otherwise, it is filled empty.
          */
-        if (FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule() != null) {
-          fillLine(dateFormat, data[i], FIN_PaymentScheduleDetail[i],
-              FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule(), false);
-        } else if (FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment() != null) {
-          java.util.List<Invoice> invoices = getInvoicesUsingCredit(FIN_PaymentScheduleDetail[i]
+        if (FIN_PaymentScheduleDetail.getInvoicePaymentSchedule() != null) {
+          fillLine(dateFormat, data, FIN_PaymentScheduleDetail,
+              FIN_PaymentScheduleDetail.getInvoicePaymentSchedule(), false);
+        } else if (FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment() != null) {
+          java.util.List<Invoice> invoices = getInvoicesUsingCredit(FIN_PaymentScheduleDetail
               .getPaymentDetails().getFinPayment());
           if (invoices.size() == 1) {
-            java.util.List<FIN_PaymentSchedule> ps = getInvoicePaymentSchedules(FIN_PaymentScheduleDetail[i]
+            java.util.List<FIN_PaymentSchedule> ps = getInvoicePaymentSchedules(FIN_PaymentScheduleDetail
                 .getPaymentDetails().getFinPayment());
-            fillLine(dateFormat, data[i], FIN_PaymentScheduleDetail[i], ps.get(0), true);
+            fillLine(dateFormat, data, FIN_PaymentScheduleDetail, ps.get(0), true);
           } else {
             // project
-            FieldProviderFactory.setField(data[i], "PROJECT", "");
+            FieldProviderFactory.setField(data, "PROJECT", "");
             // salesPerson
-            FieldProviderFactory.setField(data[i], "SALES_PERSON", "");
+            FieldProviderFactory.setField(data, "SALES_PERSON", "");
             // invoiceNumber.
-            FieldProviderFactory.setField(data[i], "INVOICE_NUMBER", invoices.size() > 1 ? "**"
+            FieldProviderFactory.setField(data, "INVOICE_NUMBER", invoices.size() > 1 ? "**"
                 + getInvoicesDocNos(invoices) : "");
             // payment plan id
-            FieldProviderFactory.setField(data[i], "PAYMENT_PLAN_ID", "");
+            FieldProviderFactory.setField(data, "PAYMENT_PLAN_ID", "");
             // payment plan yes / no
-            FieldProviderFactory.setField(data[i], "PAYMENT_PLAN_Y_N",
+            FieldProviderFactory.setField(data, "PAYMENT_PLAN_Y_N",
                 invoices.size() != 1 ? "Display:none" : "");
             // payment plan yes / no
-            FieldProviderFactory.setField(data[i], "NOT_PAYMENT_PLAN_Y_N", invoices.size() > 1 ? ""
+            FieldProviderFactory.setField(data, "NOT_PAYMENT_PLAN_Y_N", invoices.size() > 1 ? ""
                 : "Display:none");
             // invoiceDate
-            FieldProviderFactory.setField(data[i], "INVOICE_DATE", "");
+            FieldProviderFactory.setField(data, "INVOICE_DATE", "");
             // dueDate.
-            FieldProviderFactory.setField(data[i], "DUE_DATE", "");
+            FieldProviderFactory.setField(data, "DUE_DATE", "");
             // expectedDate.
-            FieldProviderFactory.setField(data[i], "EXPECTED_DATE", "");
+            FieldProviderFactory.setField(data, "EXPECTED_DATE", "");
             // plannedDSO
-            FieldProviderFactory.setField(data[i], "PLANNED_DSO", "0");
+            FieldProviderFactory.setField(data, "PLANNED_DSO", "0");
             // currentDSO
-            FieldProviderFactory.setField(data[i], "CURRENT_DSO", "0");
+            FieldProviderFactory.setField(data, "CURRENT_DSO", "0");
             // daysOverdue
-            FieldProviderFactory.setField(data[i], "OVERDUE", "0");
+            FieldProviderFactory.setField(data, "OVERDUE", "0");
           }
         } else {
           // project
-          FieldProviderFactory.setField(data[i], "PROJECT", "");
+          FieldProviderFactory.setField(data, "PROJECT", "");
           // salesPerson
-          FieldProviderFactory.setField(data[i], "SALES_PERSON", "");
+          FieldProviderFactory.setField(data, "SALES_PERSON", "");
           // invoiceNumber.
-          FieldProviderFactory.setField(data[i], "INVOICE_NUMBER", "");
+          FieldProviderFactory.setField(data, "INVOICE_NUMBER", "");
           // payment plan id
-          FieldProviderFactory.setField(data[i], "PAYMENT_PLAN_ID", "");
+          FieldProviderFactory.setField(data, "PAYMENT_PLAN_ID", "");
           // payment plan yes / no
-          FieldProviderFactory.setField(data[i], "PAYMENT_PLAN_Y_N", "Display:none");
+          FieldProviderFactory.setField(data, "PAYMENT_PLAN_Y_N", "Display:none");
           // payment plan yes / no
-          FieldProviderFactory.setField(data[i], "NOT_PAYMENT_PLAN_Y_N", "Display:none");
+          FieldProviderFactory.setField(data, "NOT_PAYMENT_PLAN_Y_N", "Display:none");
           // invoiceDate
-          FieldProviderFactory.setField(data[i], "INVOICE_DATE", "");
+          FieldProviderFactory.setField(data, "INVOICE_DATE", "");
           // dueDate.
-          FieldProviderFactory.setField(data[i], "DUE_DATE", "");
+          FieldProviderFactory.setField(data, "DUE_DATE", "");
           // expectedDate.
-          FieldProviderFactory.setField(data[i], "EXPECTED_DATE", "");
+          FieldProviderFactory.setField(data, "EXPECTED_DATE", "");
           // plannedDSO
-          FieldProviderFactory.setField(data[i], "PLANNED_DSO", "0");
+          FieldProviderFactory.setField(data, "PLANNED_DSO", "0");
           // currentDSO
-          FieldProviderFactory.setField(data[i], "CURRENT_DSO", "0");
+          FieldProviderFactory.setField(data, "CURRENT_DSO", "0");
           // daysOverdue
-          FieldProviderFactory.setField(data[i], "OVERDUE", "0");
+          FieldProviderFactory.setField(data, "OVERDUE", "0");
 
         }
 
         // transactional and base amounts
-        transAmount = FIN_PaymentScheduleDetail[i].getAmount();
+        transAmount = FIN_PaymentScheduleDetail.getAmount();
 
         Currency baseCurrency = OBDal.getInstance().get(Currency.class, strConvertCurrency);
 
@@ -878,17 +916,16 @@
           if (convRate != null) {
             final int stdPrecission = convRate.getToCurrency().getStandardPrecision().intValue();
             if (isReceipt) {
-              FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", transAmount.toString());
+              FieldProviderFactory.setField(data, "TRANS_AMOUNT", transAmount.toString());
               FieldProviderFactory.setField(
-                  data[i],
+                  data,
                   "BASE_AMOUNT",
                   transAmount.multiply(convRate.getMultipleRateBy())
                       .setScale(stdPrecission, BigDecimal.ROUND_HALF_UP).toString());
             } else {
-              FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", transAmount.negate()
-                  .toString());
+              FieldProviderFactory.setField(data, "TRANS_AMOUNT", transAmount.negate().toString());
               FieldProviderFactory.setField(
-                  data[i],
+                  data,
                   "BASE_AMOUNT",
                   transAmount.multiply(convRate.getMultipleRateBy())
                       .setScale(stdPrecission, BigDecimal.ROUND_HALF_UP).negate().toString());
@@ -901,36 +938,36 @@
         } else {
           convRate = null;
           if (isReceipt) {
-            FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", transAmount.toString());
-            FieldProviderFactory.setField(data[i], "BASE_AMOUNT", transAmount.toString());
+            FieldProviderFactory.setField(data, "TRANS_AMOUNT", transAmount.toString());
+            FieldProviderFactory.setField(data, "BASE_AMOUNT", transAmount.toString());
           } else {
-            FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", transAmount.negate().toString());
-            FieldProviderFactory.setField(data[i], "BASE_AMOUNT", transAmount.negate().toString());
+            FieldProviderFactory.setField(data, "TRANS_AMOUNT", transAmount.negate().toString());
+            FieldProviderFactory.setField(data, "BASE_AMOUNT", transAmount.negate().toString());
           }
         }
 
         // currency
-        FieldProviderFactory.setField(data[i], "BASE_CURRENCY", baseCurrency.getISOCode());
+        FieldProviderFactory.setField(data, "BASE_CURRENCY", baseCurrency.getISOCode());
         // baseCurrency
-        FieldProviderFactory.setField(data[i], "TRANS_CURRENCY", transCurrency.getISOCode());
+        FieldProviderFactory.setField(data, "TRANS_CURRENCY", transCurrency.getISOCode());
 
         // Balance
         String status = "RPAE";
         try {
-          status = FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment().getStatus();
+          status = FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().getStatus();
         } catch (NullPointerException e) {
         }
-        final boolean isCreditPayment = FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule() == null
-            && FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment() != null;
+        final boolean isCreditPayment = FIN_PaymentScheduleDetail.getInvoicePaymentSchedule() == null
+            && FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment() != null;
 
         BigDecimal balance = BigDecimal.ZERO;
         if (isCreditPayment && status != null && "PWNC RPR RPPC PPM RDNC".indexOf(status) >= 0) {
-          balance = FIN_PaymentScheduleDetail[i]
+          balance = FIN_PaymentScheduleDetail
               .getPaymentDetails()
               .getFinPayment()
               .getGeneratedCredit()
               .subtract(
-                  FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment().getUsedCredit());
+                  FIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().getUsedCredit());
           if (isReceipt) {
             balance = balance.negate();
           }
@@ -943,31 +980,30 @@
           balance = balance.multiply(convRate.getMultipleRateBy()).setScale(stdPrecission,
               BigDecimal.ROUND_HALF_UP);
         }
-        FieldProviderFactory.setField(data[i], "BALANCE", balance.toString());
+        FieldProviderFactory.setField(data, "BALANCE", balance.toString());
 
-        finPaymDetail = FIN_PaymentScheduleDetail[i].getPaymentDetails();
+        finPaymDetail = FIN_PaymentScheduleDetail.getPaymentDetails();
 
         // Payment Schedule Detail grouping criteria
-        if (finPaymDetail != null
-            && FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule() != null) {
+        if (finPaymDetail != null && FIN_PaymentScheduleDetail.getInvoicePaymentSchedule() != null) {
           mustGroup = finPaymDetail.getFinPayment().getId().equalsIgnoreCase(previousPaymentId)
-              && FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getId()
+              && FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getId()
                   .equalsIgnoreCase(previousFPSDInvoiceId);
-          previousFPSDInvoiceId = FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getId();
+          previousFPSDInvoiceId = FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getId();
           previousPaymentId = finPaymDetail.getFinPayment().getId();
         } else if (finPaymDetail != null
-            && FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule() == null) {
+            && FIN_PaymentScheduleDetail.getInvoicePaymentSchedule() == null) {
           mustGroup = finPaymDetail.getFinPayment().getId().equalsIgnoreCase(previousPaymentId)
               && previousFPSDInvoiceId == null;
           previousPaymentId = finPaymDetail.getFinPayment().getId();
           previousFPSDInvoiceId = null;
         } else if (finPaymDetail == null
-            && FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule() != null) {
+            && FIN_PaymentScheduleDetail.getInvoicePaymentSchedule() != null) {
           mustGroup = previousPaymentId == null
-              && FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getId()
+              && FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getId()
                   .equalsIgnoreCase(previousFPSDInvoiceId);
           previousPaymentId = null;
-          previousFPSDInvoiceId = FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule().getId();
+          previousFPSDInvoiceId = FIN_PaymentScheduleDetail.getInvoicePaymentSchedule().getId();
         } else {
           mustGroup = false;
         }
@@ -1023,12 +1059,12 @@
                       .parseDouble(strAmountTo);
             }
             if (isAmtInLimit) {
-              groupedData.add(previousRow);
+              lastGroupedDatarow = previousRow;
               isAmtInLimit = false;
               numberOfElements++;
             }
           }
-          previousRow = data[i];
+          previousRow = data;
           previousConvRate = convRate;
           amountSum = transAmount;
           balanceSum = balance;
@@ -1063,15 +1099,14 @@
         if (lastElement != numberOfElements) {
           if (transactionsList.size() > 0) {
             try {
-              existsConvRate = insertIntoTotal(groupedData.get(lastElement), transactionsList,
-                  totalData, strGroupCrit, strOrdCrit, transactionData, totalTransElements,
-                  strConvertCurrency, strConversionDate);
+              existsConvRate = insertIntoTotal(lastGroupedDatarow, transactionsList, totalData,
+                  strGroupCrit, strOrdCrit, strConvertCurrency, strConversionDate);
             } catch (OBException e) {
               // If there is no conversion rate
               throw e;
             }
           }
-          totalData.add(groupedData.get(lastElement));
+          totalData.add(lastGroupedDatarow);
           lastElement++;
         }
 
@@ -1122,7 +1157,7 @@
                   .parseDouble(strAmountTo);
         }
         if (isAmtInLimit) {
-          groupedData.add(previousRow);
+          lastGroupedDatarow = previousRow;
           isAmtInLimit = false;
           numberOfElements++;
         }
@@ -1132,33 +1167,29 @@
       if (lastElement != numberOfElements) {
         if (transactionsList.size() > 0) {
           try {
-            existsConvRate = insertIntoTotal(groupedData.get(lastElement), transactionsList,
-                totalData, strGroupCrit, strOrdCrit, transactionData, totalTransElements,
-                strConvertCurrency, strConversionDate);
+            existsConvRate = insertIntoTotal(lastGroupedDatarow, transactionsList, totalData,
+                strGroupCrit, strOrdCrit, strConvertCurrency, strConversionDate);
           } catch (OBException e) {
             // If there is no conversion rate
             throw e;
           }
         }
-        totalData.add(groupedData.get(lastElement));
+        totalData.add(lastGroupedDatarow);
         lastElement++;
       }
 
       // Insert the remaining transactions wihtout payment if necessary
       while (transactionsList.size() > 0) {
-        try {
-          transactionData[totalTransElements - transactionsList.size()] = createFieldProviderForTransaction(
-              transactionsList.get(0),
-              transactionData[totalTransElements - transactionsList.size()], strGroupCrit,
-              strConvertCurrency, strConversionDate);
-        } catch (OBException e) {
-          // If there is no conversion rate
-          throw e;
-        }
-        totalData.add(transactionData[totalTransElements - transactionsList.size()]);
+        // throws OBException if there is no conversion rate
+        FieldProvider transactionData = createFieldProviderForTransaction(transactionsList.get(0),
+            strGroupCrit, strConvertCurrency, strConversionDate);
+        totalData.add(transactionData);
         transactionsList.remove(0);
       }
     } finally {
+      if (scroller != null) {
+        scroller.close();
+      }
       OBContext.restorePreviousMode();
     }
     return (FieldProvider[]) totalData.toArray(new FieldProvider[totalData.size()]);
@@ -1175,21 +1206,15 @@
    */
   private boolean insertIntoTotal(FieldProvider data,
       java.util.List<FIN_FinaccTransaction> transactionsList, ArrayList<FieldProvider> totalData,
-      String strGroupCrit, String strOrdCrit, FieldProvider[] transactionData,
-      int totalTransElements, String strConvertCurrency, String strConversionDate)
+      String strGroupCrit, String strOrdCrit, String strConvertCurrency, String strConversionDate)
       throws OBException {
 
     while (transactionsList.size() > 0
         && transactionIsBefore(transactionsList.get(0), data, strGroupCrit, strOrdCrit)) {
-      try {
-        transactionData[totalTransElements - transactionsList.size()] = createFieldProviderForTransaction(
-            transactionsList.get(0), transactionData[totalTransElements - transactionsList.size()],
-            strGroupCrit, strConvertCurrency, strConversionDate);
-      } catch (OBException e) {
-        // If there is no conversion rate
-        throw e;
-      }
-      totalData.add(transactionData[totalTransElements - transactionsList.size()]);
+      // throws OBException if there is no conversion rate
+      FieldProvider transactionData = createFieldProviderForTransaction(transactionsList.get(0),
+          strGroupCrit, strConvertCurrency, strConversionDate);
+      totalData.add(transactionData);
       transactionsList.remove(0);
     }
     return true;
@@ -1203,14 +1228,16 @@
    * @throws OBException
    */
   private FieldProvider createFieldProviderForTransaction(FIN_FinaccTransaction transaction,
-      FieldProvider transactionData, String strGroupCrit, String strConvertCurrency,
-      String strConversionDate) throws OBException {
+      String strGroupCrit, String strConvertCurrency, String strConversionDate) throws OBException {
     String dateFormatString = OBPropertiesProvider.getInstance().getOpenbravoProperties()
         .getProperty("dateFormat.java");
     SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString);
     BigDecimal transAmount = null;
     ConversionRate convRate = null;
 
+    // call with null to return empty map without any link to a dal object
+    FieldProvider transactionData = FieldProviderFactory.getFieldProvider(null);
+
     // bp_group -- bp_category
     if (transaction.getBusinessPartner() != null) {
       FieldProviderFactory.setField(transactionData, "BP_GROUP", transaction.getBusinessPartner()
--- a/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -6,7 +6,7 @@
 <!--3A3A943684D64DEF9EC39F588A656848-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <NAME><![CDATA[Orders Awaiting Delivery]]></NAME>
-<!--3A3A943684D64DEF9EC39F588A656848-->  <VERSION><![CDATA[1.1.23921]]></VERSION>
+<!--3A3A943684D64DEF9EC39F588A656848-->  <VERSION><![CDATA[1.1.24368]]></VERSION>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <DESCRIPTION><![CDATA[Report displaying sales orders not shipped.]]></DESCRIPTION>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <URL><![CDATA[http://forge.openbravo.com/projects/ordersawaitingdlivery]]></URL>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <TYPE><![CDATA[M]]></TYPE>
--- a/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 13:46:43 2014 +0200
+++ b/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed Sep 03 16:32:14 2014 +0200
@@ -7,7 +7,7 @@
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <AD_MODULE_ID><![CDATA[3A3A943684D64DEF9EC39F588A656848]]></AD_MODULE_ID>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <STARTVERSION><![CDATA[3.0.23921]]></STARTVERSION>
+<!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <STARTVERSION><![CDATA[3.0.24368]]></STARTVERSION>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED><