Related with bug 29612:New grid configuration to improve population of fk combo
authorAugusto Mauch <augusto.mauch@openbravo.com>
Fri, 08 May 2015 12:39:56 +0200
changeset 27111 aa165ef81792
parent 26612 e8b37e1f8639
child 27112 e684c73bb502
Related with bug 29612:New grid configuration to improve population of fk combo

The new grid configuration allows to change the way the foreign key filter drop downs are populated. Usually the rows shown in a fk filter drop down are only those that are being used in the referencing table. But that can be very slow if the referenced table has only a few records and the referenced tablas has a huge volume.

To address this problem, this new grid configuration allows to show all the records of the referenced table, even if they are not being used in the referencing table. When the queryService is being created to populate the filter drop down, the main entity is changed to the referenced table, and the criteria is updated. Also the where clause of the referencing table is now ignored.
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Fri May 08 12:39:56 2015 +0200
@@ -65,6 +65,10 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault><![CDATA['D']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <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	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml	Fri May 08 12:39:56 2015 +0200
@@ -61,6 +61,10 @@
         <default><![CDATA[Y]]></default>
         <onCreateDefault><![CDATA['Y']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_SYSTEM_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -74,5 +78,6 @@
       <check name="OBUIAPP_GC_SYS_ISLAZY_CHK"><![CDATA[ISLAZYFILTERING IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ISSORT_CHK"><![CDATA[ISSORTABLE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ONCHNG_CHK"><![CDATA[FILTERONCHANGE IN ('Y', 'N')]]></check>
+      <check name="OBUIAPP_GC_SYS_UNFILTDD_CHK"><![CDATA[ISFKDROPDOWNUNFILTERED IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Fri May 08 12:39:56 2015 +0200
@@ -65,6 +65,10 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault><![CDATA['D']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <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/sourcedata/AD_COLUMN.xml	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Fri May 08 12:39:56 2015 +0200
@@ -2470,6 +2470,42 @@
 <!--40BF5714171243E0BF9928C4D08E1B17-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--40BF5714171243E0BF9928C4D08E1B17--></AD_COLUMN>
 
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2--><AD_COLUMN>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_COLUMN_ID><![CDATA[40C3D2FBF24A4094B5061F1D6F64C8D2]]></AD_COLUMN_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <NAME><![CDATA[IsFkDropDownUnfiltered]]></NAME>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_TABLE_ID><![CDATA[5D50320222DD4865ADFD50364C84291D]]></AD_TABLE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <SEQNO><![CDATA[160]]></SEQNO>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <POSITION><![CDATA[16]]></POSITION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2--></AD_COLUMN>
+
 <!--416B600071A3481FAFF4B9CE6EB2B991--><AD_COLUMN>
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <AD_COLUMN_ID><![CDATA[416B600071A3481FAFF4B9CE6EB2B991]]></AD_COLUMN_ID>
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2506,6 +2542,43 @@
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--416B600071A3481FAFF4B9CE6EB2B991--></AD_COLUMN>
 
+<!--4651E1FC435744898055E3BE4D2F9A88--><AD_COLUMN>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_COLUMN_ID><![CDATA[4651E1FC435744898055E3BE4D2F9A88]]></AD_COLUMN_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <NAME><![CDATA[IsFkDropDownUnfiltered]]></NAME>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_TABLE_ID><![CDATA[8A16662B37184121A1EDAA89890E160C]]></AD_TABLE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <POSITION><![CDATA[17]]></POSITION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--4651E1FC435744898055E3BE4D2F9A88--></AD_COLUMN>
+
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE--><AD_COLUMN>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <AD_COLUMN_ID><![CDATA[4737ABA46AA14ACAB3BF0D8DB72F3EFE]]></AD_COLUMN_ID>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2542,6 +2615,43 @@
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE--></AD_COLUMN>
 
+<!--48A069D3607C4ACEA7ACCBA679A00B75--><AD_COLUMN>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_COLUMN_ID><![CDATA[48A069D3607C4ACEA7ACCBA679A00B75]]></AD_COLUMN_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <NAME><![CDATA[IsFkDropdownUnfiltered]]></NAME>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_TABLE_ID><![CDATA[F167EB822B8A4284AC37D5B40B785D51]]></AD_TABLE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <POSITION><![CDATA[17]]></POSITION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75--></AD_COLUMN>
+
 <!--48FAAFCA11A143169FD7517D67531DD1--><AD_COLUMN>
 <!--48FAAFCA11A143169FD7517D67531DD1-->  <AD_COLUMN_ID><![CDATA[48FAAFCA11A143169FD7517D67531DD1]]></AD_COLUMN_ID>
 <!--48FAAFCA11A143169FD7517D67531DD1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Fri May 08 12:39:56 2015 +0200
@@ -133,6 +133,20 @@
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4--></AD_ELEMENT>
 
+<!--2D51BCE155184D34A5F38FFE515D5C23--><AD_ELEMENT>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <COLUMNNAME><![CDATA[IsFkDropDownUnfiltered]]></COLUMNNAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <NAME><![CDATA[Is FK Dropdown Unfiltered]]></NAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <PRINTNAME><![CDATA[Is FK Dropdown Unfiltered]]></PRINTNAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--2D51BCE155184D34A5F38FFE515D5C23--></AD_ELEMENT>
+
 <!--31DCDECE67A34C418930D50405D8057D--><AD_ELEMENT>
 <!--31DCDECE67A34C418930D50405D8057D-->  <AD_ELEMENT_ID><![CDATA[31DCDECE67A34C418930D50405D8057D]]></AD_ELEMENT_ID>
 <!--31DCDECE67A34C418930D50405D8057D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Fri May 08 12:39:56 2015 +0200
@@ -3341,6 +3341,34 @@
 <!--8E499D659EDA4527B7E179CC4C065F04-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--8E499D659EDA4527B7E179CC4C065F04--></AD_FIELD>
 
+<!--90A8FCE2F0674325863B3F793AB79601--><AD_FIELD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_FIELD_ID><![CDATA[90A8FCE2F0674325863B3F793AB79601]]></AD_FIELD_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <NAME><![CDATA[Is FK Dropdown Unfiltered]]></NAME>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_TAB_ID><![CDATA[D26230D6D21546C6970E79FF1C51165E]]></AD_TAB_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_COLUMN_ID><![CDATA[48A069D3607C4ACEA7ACCBA679A00B75]]></AD_COLUMN_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <SEQNO><![CDATA[510]]></SEQNO>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--90A8FCE2F0674325863B3F793AB79601--></AD_FIELD>
+
 <!--92EDD1AEF5B545648BB0F8FE550ACF67--><AD_FIELD>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <AD_FIELD_ID><![CDATA[92EDD1AEF5B545648BB0F8FE550ACF67]]></AD_FIELD_ID>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4662,6 +4690,34 @@
 <!--D6FC282E5E614AED8C301C8FEC0436FB-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--D6FC282E5E614AED8C301C8FEC0436FB--></AD_FIELD>
 
+<!--D8A9991BA87645D987BA8B8C9B1C956F--><AD_FIELD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_FIELD_ID><![CDATA[D8A9991BA87645D987BA8B8C9B1C956F]]></AD_FIELD_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <NAME><![CDATA[Is FK Dropdown Unfiltered]]></NAME>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_TAB_ID><![CDATA[13FE911F7F684A47801DF55525BAD4A1]]></AD_TAB_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_COLUMN_ID><![CDATA[40C3D2FBF24A4094B5061F1D6F64C8D2]]></AD_COLUMN_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <SEQNO><![CDATA[510]]></SEQNO>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F--></AD_FIELD>
+
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B--><AD_FIELD>
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B-->  <AD_FIELD_ID><![CDATA[D9056C5C10E548E1B9BB5FAC9B61AA1B]]></AD_FIELD_ID>
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -5179,6 +5235,34 @@
 <!--F684BC3FC0E64CFFA0D0A57A926DC043-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--F684BC3FC0E64CFFA0D0A57A926DC043--></AD_FIELD>
 
+<!--F71536CBC10F40BAAC048E466C2E8916--><AD_FIELD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_FIELD_ID><![CDATA[F71536CBC10F40BAAC048E466C2E8916]]></AD_FIELD_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <NAME><![CDATA[Is FK Dropdown Unfiltered]]></NAME>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_TAB_ID><![CDATA[49B33DC2EDFD45A48EECE139AD5E9AC9]]></AD_TAB_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_COLUMN_ID><![CDATA[4651E1FC435744898055E3BE4D2F9A88]]></AD_COLUMN_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <SEQNO><![CDATA[510]]></SEQNO>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--F71536CBC10F40BAAC048E466C2E8916--></AD_FIELD>
+
 <!--F885A0CC89634D07A19F99F762702658--><AD_FIELD>
 <!--F885A0CC89634D07A19F99F762702658-->  <AD_FIELD_ID><![CDATA[F885A0CC89634D07A19F99F762702658]]></AD_FIELD_ID>
 <!--F885A0CC89634D07A19F99F762702658-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Fri May 08 12:39:56 2015 +0200
@@ -177,6 +177,7 @@
     Boolean filterOnChange = null;
     Boolean lazyFiltering = null;
     Boolean allowFkFilterByIdentifier = null;
+    Boolean showFkDropdownUnfiltered = null;
     String operator = null;
     Long thresholdToFilter = null;
     JSONObject result = new JSONObject();
@@ -225,6 +226,13 @@
               allowFkFilterByIdentifier = false;
             }
           }
+          if (showFkDropdownUnfiltered == null) {
+            if ("Y".equals(fieldConfs.get(0).getIsFkDropdownUnfiltered())) {
+              showFkDropdownUnfiltered = true;
+            } else if ("N".equals(fieldConfs.get(0).getIsFkDropdownUnfiltered())) {
+              showFkDropdownUnfiltered = false;
+            }
+          }
           if (thresholdToFilter == null) {
             thresholdToFilter = fieldConfs.get(0).getThresholdToFilter();
           }
@@ -233,7 +241,8 @@
     }
 
     if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-        || thresholdToFilter == null || allowFkFilterByIdentifier == null) {
+        || thresholdToFilter == null || allowFkFilterByIdentifier == null
+        || showFkDropdownUnfiltered == null) {
       List<Object> tabParams = new ArrayList<Object>();
       String tabConfsHql = " as p where p.tab.id = ? ";
       tabParams.add(tab.getId());
@@ -282,7 +291,13 @@
             allowFkFilterByIdentifier = false;
           }
         }
-
+        if (showFkDropdownUnfiltered == null) {
+          if ("Y".equals(tabConfs.get(0).getIsFkDropDownUnfiltered())) {
+            showFkDropdownUnfiltered = true;
+          } else if ("N".equals(tabConfs.get(0).getIsFkDropDownUnfiltered())) {
+            showFkDropdownUnfiltered = false;
+          }
+        }
         if (thresholdToFilter == null) {
           thresholdToFilter = tabConfs.get(0).getThresholdToFilter();
         }
@@ -290,7 +305,7 @@
     }
 
     if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-        || thresholdToFilter == null) {
+        || thresholdToFilter == null || showFkDropdownUnfiltered == null) {
       // Trying to get parameters from "Grid Configuration (System)" window
       List<GCSystem> sysConfs = OBDal.getInstance().createQuery(GCSystem.class, "").list();
       if (!sysConfs.isEmpty()) {
@@ -315,6 +330,9 @@
         if (allowFkFilterByIdentifier == null) {
           allowFkFilterByIdentifier = sysConfs.get(0).isAllowFilterByIdentifier();
         }
+        if (showFkDropdownUnfiltered == null) {
+          showFkDropdownUnfiltered = sysConfs.get(0).isFkDropDownUnfiltered();
+        }
       }
     }
 
@@ -357,6 +375,9 @@
       if (allowFkFilterByIdentifier != null) {
         result.put("allowFkFilterByIdentifier", allowFkFilterByIdentifier);
       }
+      if (showFkDropdownUnfiltered != null) {
+        result.put("showFkDropdownUnfiltered", showFkDropdownUnfiltered);
+      }
     } catch (JSONException e) {
       log.error("Couldn't get field property value");
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Fri May 08 12:39:56 2015 +0200
@@ -180,6 +180,9 @@
     if (grid.Class === 'OBTreeGrid') {
       dataSource.requestProperties.params.tabId = grid.view.tabId;
     }
+    if (this.showFkDropdownUnfiltered) {
+        dataSource.requestProperties.params._showFkDropdownUnfiltered = true;
+    }
     this.setOptionDataSource(dataSource);
 
     this.Super('init', arguments);
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Fri May 08 12:39:56 2015 +0200
@@ -68,6 +68,11 @@
       append = append + ", allowFkFilterByIdentifier: " + allowFkFilterByIdentifier.toString();
     }
 
+    Boolean showFkDropdownUnfiltered = (Boolean) readGridConfigurationSetting("showFkDropdownUnfiltered");
+    if (Boolean.TRUE.equals(showFkDropdownUnfiltered)) {
+      append = append + ", showFkDropdownUnfiltered: " + showFkDropdownUnfiltered.toString();
+    }
+
     return super.getFilterEditorPropertiesProperty(field) + append;
   }
 
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Fri May 08 12:39:56 2015 +0200
@@ -327,71 +327,114 @@
       // this is the main entity of a 'contains' (used in FK drop down lists), it will create also
       // info for subentity
 
-      final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
-      final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
-          .getEntity(entityName), distinctPropertyPath);
-      final Entity distinctEntity = distinctProperty.getTargetEntity();
+      if ("true".equals(parameters.get(JsonConstants.SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER))) {
+        // Do not filter out the rows of the referenced tables if
+        // they are not referenced from the referencing tables
+        // Showing the records unfiltered improves the performance if the referenced table has just
+        // a few records and the referencing table has lots
+        final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
+        final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
+            .getEntity(entityName), distinctPropertyPath);
+        final Entity distinctEntity = distinctProperty.getTargetEntity();
+        queryService.setEntityName(distinctEntity.getName());
+        queryService.setFilterOnReadableOrganizations(filterOnReadableOrganizations);
+        if (parameters.containsKey(JsonConstants.USE_ALIAS)) {
+          queryService.setUseAlias();
+        }
 
-      // criteria needs to be split in two parts:
-      // -One for main entity (the one directly queried for)
-      // -Another one for subentity
-      String baseCriteria = "";
-      String subCriteria = "";
-      hasSubentity = true;
-      if (!StringUtils.isEmpty(parameters.get("criteria"))) {
-        String criteria = parameters.get("criteria");
-        for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
-          try {
-            JSONObject jsonCriterion = new JSONObject(criterion);
-            if (jsonCriterion.getString("fieldName").equals(
-                distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
-              jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
-              baseCriteria = jsonCriterion.toString();
-            } else {
-              subCriteria += subCriteria.length() > 0 ? JsonConstants.IN_PARAMETER_SEPARATOR : "";
-              subCriteria += criterion;
+        String baseCriteria = "";
+        // The main entity is now the referenced table, so each criterion that references it must be
+        // updated
+        // The criteria that does not apply to the referenced table can be ignored
+        if (!StringUtils.isEmpty(parameters.get("criteria"))) {
+          String criteria = parameters.get("criteria");
+          for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
+            try {
+              JSONObject jsonCriterion = new JSONObject(criterion);
+              if (jsonCriterion.getString("fieldName").equals(
+                  distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
+                jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
+                baseCriteria = jsonCriterion.toString();
+              }
+            } catch (JSONException e) {
+              log.error("Error obtaining 'distint' criterion for " + criterion, e);
             }
-          } catch (JSONException e) {
-            log.error("Error obtaining 'distint' criterion for " + criterion, e);
           }
         }
+        if (StringUtils.isEmpty(baseCriteria)) {
+          parameters.remove("criteria");
+        } else {
+          parameters.put("criteria", baseCriteria);
+        }
+        // The where clause of the referencing table no longer needs to be applied, as the query
+        // will be done on the referenced table
+        removeWhereParameter(parameters);
+      } else {
+
+        final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
+        final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
+            .getEntity(entityName), distinctPropertyPath);
+        final Entity distinctEntity = distinctProperty.getTargetEntity();
+
+        // criteria needs to be split in two parts:
+        // -One for main entity (the one directly queried for)
+        // -Another one for subentity
+        String baseCriteria = "";
+        String subCriteria = "";
+        hasSubentity = true;
+        if (!StringUtils.isEmpty(parameters.get("criteria"))) {
+          String criteria = parameters.get("criteria");
+          for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
+            try {
+              JSONObject jsonCriterion = new JSONObject(criterion);
+              if (jsonCriterion.getString("fieldName").equals(
+                  distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
+                jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
+                baseCriteria = jsonCriterion.toString();
+              } else {
+                subCriteria += subCriteria.length() > 0 ? JsonConstants.IN_PARAMETER_SEPARATOR : "";
+                subCriteria += criterion;
+              }
+            } catch (JSONException e) {
+              log.error("Error obtaining 'distint' criterion for " + criterion, e);
+            }
+          }
+        }
+
+        // params for subentity are based on main entity ones
+        @SuppressWarnings("unchecked")
+        Map<String, String> paramSubCriteria = (Map<String, String>) ((HashMap<String, String>) parameters)
+            .clone();
+
+        // set proper criteria for each case
+        if (StringUtils.isEmpty(subCriteria)) {
+          paramSubCriteria.remove("criteria");
+        } else {
+          paramSubCriteria.put("criteria", subCriteria);
+        }
+        if (StringUtils.isEmpty(baseCriteria)) {
+          parameters.remove("criteria");
+        } else {
+          parameters.put("criteria", baseCriteria);
+        }
+
+        // where parameter is only applied in subentity, remove it from main entity
+        removeWhereParameter(parameters);
+
+        // main entity ("me") settings
+        queryService.getQueryBuilder().setMainAlias("me");
+        queryService.setEntityName(distinctEntity.getName());
+
+        queryService.setFilterOnReadableClients(false);
+        queryService.setFilterOnReadableOrganizations(false);
+        queryService.setFilterOnActive(false);
+
+        // create now subentity
+        queryService.setSubEntity(
+            entityName,
+            createSetQueryService(paramSubCriteria, forCountOperation, true,
+                filterOnReadableOrganizations), distinctProperty, distinctPropertyPath);
       }
-
-      // params for subentity are based on main entity ones
-      @SuppressWarnings("unchecked")
-      Map<String, String> paramSubCriteria = (Map<String, String>) ((HashMap<String, String>) parameters)
-          .clone();
-
-      // set proper criteria for each case
-      if (StringUtils.isEmpty(subCriteria)) {
-        paramSubCriteria.remove("criteria");
-      } else {
-        paramSubCriteria.put("criteria", subCriteria);
-      }
-      if (StringUtils.isEmpty(baseCriteria)) {
-        parameters.remove("criteria");
-      } else {
-        parameters.put("criteria", baseCriteria);
-      }
-
-      // where parameter is only applied in subentity, remove it from main entity
-      if (parameters.containsKey(JsonConstants.WHERE_PARAMETER)) {
-        parameters.remove(JsonConstants.WHERE_PARAMETER);
-      }
-
-      // main entity ("me") settings
-      queryService.getQueryBuilder().setMainAlias("me");
-      queryService.setEntityName(distinctEntity.getName());
-
-      queryService.setFilterOnReadableClients(false);
-      queryService.setFilterOnReadableOrganizations(false);
-      queryService.setFilterOnActive(false);
-
-      // create now subentity
-      queryService.setSubEntity(
-          entityName,
-          createSetQueryService(paramSubCriteria, forCountOperation, true,
-              filterOnReadableOrganizations), distinctProperty, distinctPropertyPath);
     } else {
       queryService.setEntityName(entityName);
       queryService.setFilterOnReadableOrganizations(filterOnReadableOrganizations);
@@ -522,6 +565,12 @@
     return queryService;
   }
 
+  private void removeWhereParameter(Map<String, String> parameters) {
+    if (parameters.containsKey(JsonConstants.WHERE_PARAMETER)) {
+      parameters.remove(JsonConstants.WHERE_PARAMETER);
+    }
+  }
+
   // Given a map of parameters, returns a string with the pairs key:value
   private String convertParameterToString(Map<String, String> parameters) {
     String paramMsg = "";
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java	Mon May 11 19:21:58 2015 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java	Fri May 08 12:39:56 2015 +0200
@@ -56,6 +56,7 @@
   public static final String WHERE_PARAMETER = "_where";
   public static final String SELECTEDPROPERTIES_PARAMETER = "_selectedProperties";
   public static final String DISTINCT_PARAMETER = "_distinct";
+  public static final String SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER = "_showFkDropdownUnfiltered";
   public static final String SUMMARY_PARAMETER = "_summary";
   public static final String ORDERBY_PARAMETER = "_orderBy";
   public static final String FILTER_PARAMETER = "_filter";