IDEMPIERE-4645 Search by special field types failing (#524)

* IDEMPIERE-4645 Search by special field types failing

* Set the advanced operators for Search for the special cases
This commit is contained in:
Carlos Ruiz 2021-01-17 11:05:06 +01:00 committed by GitHub
parent 0e366c9929
commit fa8b7f1807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 174 additions and 16 deletions

View File

@ -0,0 +1,43 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4645 Search by special field types failing
-- Jan 13, 2021, 10:35:06 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200180,'M_AttributeSetInstance','Attribute Set Instance','T',0,0,'Y',TO_DATE('2021-01-13 10:35:06','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:35:06','YYYY-MM-DD HH24:MI:SS'),100,'D','N','b5bbd62d-3952-41a0-a24a-552917766c57')
;
-- Jan 13, 2021, 10:35:52 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200180,559,8472,8479,0,0,'Y',TO_DATE('2021-01-13 10:35:52','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:35:52','YYYY-MM-DD HH24:MI:SS'),100,'N','D','4606d4f7-fa80-424a-b8fb-ab7930a5505f')
;
-- Jan 13, 2021, 10:36:17 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200181,'S_ResourceAssignment','Resource Assignment','T',0,0,'Y',TO_DATE('2021-01-13 10:36:17','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:36:17','YYYY-MM-DD HH24:MI:SS'),100,'D','N','0fbb9b88-bec0-437e-baff-b5fc8d98f5e0')
;
-- Jan 13, 2021, 10:37:56 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200181,485,6834,6937,0,0,'Y',TO_DATE('2021-01-13 10:37:56','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:37:56','YYYY-MM-DD HH24:MI:SS'),100,'N','D','3c361623-901d-4232-a71f-9633cdb68a5c')
;
-- Jan 13, 2021, 10:38:14 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200182,'AD_Image','Image','T',0,0,'Y',TO_DATE('2021-01-13 10:38:14','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:38:14','YYYY-MM-DD HH24:MI:SS'),100,'D','N','3c7cb70b-e7e0-47e6-a21b-da42a725e5d5')
;
-- Jan 13, 2021, 10:38:32 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200182,461,6287,6295,0,0,'Y',TO_DATE('2021-01-13 10:38:32','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:38:32','YYYY-MM-DD HH24:MI:SS'),100,'N','D','04075c33-d72b-400c-8221-555c030f2b02')
;
-- Jan 13, 2021, 10:39:01 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200183,'AD_Chart','Chart','T',0,0,'Y',TO_DATE('2021-01-13 10:39:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:39:01','YYYY-MM-DD HH24:MI:SS'),100,'D','N','19401d65-0125-41ab-a79d-6a149aa4d670')
;
-- Jan 13, 2021, 10:39:27 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200183,53284,59694,59696,0,0,'Y',TO_DATE('2021-01-13 10:39:26','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-01-13 10:39:26','YYYY-MM-DD HH24:MI:SS'),100,'N','D','ec15b1d8-3800-43b8-b311-1e5ef9ce09e4')
;
-- Jan 13, 2021, 11:45:32 AM CET
UPDATE AD_Ref_Table SET AD_Display=2400,Updated=TO_DATE('2021-01-13 11:45:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=175
;
SELECT register_migration_script('202101131048_IDEMPIERE-4645.sql') FROM dual
;

View File

@ -0,0 +1,40 @@
-- IDEMPIERE-4645 Search by special field types failing
-- Jan 13, 2021, 10:35:06 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200180,'M_AttributeSetInstance','Attribute Set Instance','T',0,0,'Y',TO_TIMESTAMP('2021-01-13 10:35:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:35:06','YYYY-MM-DD HH24:MI:SS'),100,'D','N','b5bbd62d-3952-41a0-a24a-552917766c57')
;
-- Jan 13, 2021, 10:35:52 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200180,559,8472,8479,0,0,'Y',TO_TIMESTAMP('2021-01-13 10:35:52','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:35:52','YYYY-MM-DD HH24:MI:SS'),100,'N','D','4606d4f7-fa80-424a-b8fb-ab7930a5505f')
;
-- Jan 13, 2021, 10:36:17 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200181,'S_ResourceAssignment','Resource Assignment','T',0,0,'Y',TO_TIMESTAMP('2021-01-13 10:36:17','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:36:17','YYYY-MM-DD HH24:MI:SS'),100,'D','N','0fbb9b88-bec0-437e-baff-b5fc8d98f5e0')
;
-- Jan 13, 2021, 10:37:56 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200181,485,6834,6937,0,0,'Y',TO_TIMESTAMP('2021-01-13 10:37:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:37:56','YYYY-MM-DD HH24:MI:SS'),100,'N','D','3c361623-901d-4232-a71f-9633cdb68a5c')
;
-- Jan 13, 2021, 10:38:14 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200182,'AD_Image','Image','T',0,0,'Y',TO_TIMESTAMP('2021-01-13 10:38:14','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:38:14','YYYY-MM-DD HH24:MI:SS'),100,'D','N','3c7cb70b-e7e0-47e6-a21b-da42a725e5d5')
;
-- Jan 13, 2021, 10:38:32 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200182,461,6287,6295,0,0,'Y',TO_TIMESTAMP('2021-01-13 10:38:32','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:38:32','YYYY-MM-DD HH24:MI:SS'),100,'N','D','04075c33-d72b-400c-8221-555c030f2b02')
;
-- Jan 13, 2021, 10:39:01 AM CET
INSERT INTO AD_Reference (AD_Reference_ID,Name,Description,ValidationType,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,IsOrderByValue,AD_Reference_UU) VALUES (200183,'AD_Chart','Chart','T',0,0,'Y',TO_TIMESTAMP('2021-01-13 10:39:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:39:01','YYYY-MM-DD HH24:MI:SS'),100,'D','N','19401d65-0125-41ab-a79d-6a149aa4d670')
;
-- Jan 13, 2021, 10:39:27 AM CET
INSERT INTO AD_Ref_Table (AD_Reference_ID,AD_Table_ID,AD_Key,AD_Display,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsValueDisplayed,EntityType,AD_Ref_Table_UU) VALUES (200183,53284,59694,59696,0,0,'Y',TO_TIMESTAMP('2021-01-13 10:39:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-01-13 10:39:26','YYYY-MM-DD HH24:MI:SS'),100,'N','D','ec15b1d8-3800-43b8-b311-1e5ef9ce09e4')
;
-- Jan 13, 2021, 11:45:32 AM CET
UPDATE AD_Ref_Table SET AD_Display=2400,Updated=TO_TIMESTAMP('2021-01-13 11:45:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=175
;
SELECT register_migration_script('202101131048_IDEMPIERE-4645.sql') FROM dual
;

View File

@ -106,11 +106,13 @@ public class SystemIDs
public final static int REFERENCE_DATATYPE_ASSIGNMENT = 33;
public final static int REFERENCE_DATATYPE_BINARY = 23;
public final static int REFERENCE_DATATYPE_BUTTON = 28;
public final static int REFERENCE_DATATYPE_CHART = 53370;
public final static int REFERENCE_DATATYPE_CHOSEN_MULTIPLE_SELECTION_LIST = 200161;
public final static int REFERENCE_DATATYPE_CHOSEN_MULTIPLE_SELECTION_TABLE = 200162;
public final static int REFERENCE_DATATYPE_CHOSEN_MULTIPLE_SELECTION_SEARCH = 200163;
public final static int REFERENCE_DATATYPE_CHOSEN_MULTIPLE_SELECTION_TABLE = 200162;
public final static int REFERENCE_DATATYPE_COLOR = 27;
public final static int REFERENCE_DATATYPE_COSTPRICE = 37;
public final static int REFERENCE_DATATYPE_DASHBOARD_CONTENT = 200122;
public final static int REFERENCE_DATATYPE_DATE = 15;
public final static int REFERENCE_DATATYPE_DATETIME = 16;
public final static int REFERENCE_DATATYPE_FILENAME = 39;
@ -122,6 +124,7 @@ public class SystemIDs
public final static int REFERENCE_DATATYPE_LOCATION = 21;
public final static int REFERENCE_DATATYPE_LOCATOR = 31;
public final static int REFERENCE_DATATYPE_MEMO = 34;
public final static int REFERENCE_DATATYPE_MULTIPLE_SELECTION_GRID = 200128;
public final static int REFERENCE_DATATYPE_NUMBER = 22;
public final static int REFERENCE_DATATYPE_PAYMENT = 200012;
public final static int REFERENCE_DATATYPE_PRINTNAME = 42;
@ -130,6 +133,7 @@ public class SystemIDs
public final static int REFERENCE_DATATYPE_RADIOGROUP_LIST= 200152;
public final static int REFERENCE_DATATYPE_ROWID = 26;
public final static int REFERENCE_DATATYPE_SEARCH = 30;
public final static int REFERENCE_DATATYPE_SINGLE_SELECTION_GRID = 200127;
public final static int REFERENCE_DATATYPE_STRING = 10;
public final static int REFERENCE_DATATYPE_TABLE = 18;
public final static int REFERENCE_DATATYPE_TABLEDIR = 19;
@ -138,22 +142,25 @@ public class SystemIDs
public final static int REFERENCE_DATATYPE_TIME = 24;
public final static int REFERENCE_DATATYPE_URL = 40;
public final static int REFERENCE_DATATYPE_YES_NO = 20;
public final static int REFERENCE_DATATYPE_CHART = 53370;
public final static int REFERENCE_DATATYPE_DASHBOARD_CONTENT = 200122;
public final static int REFERENCE_DATATYPE_SINGLE_SELECTION_GRID = 200127;
public final static int REFERENCE_DATATYPE_MULTIPLE_SELECTION_GRID = 200128;
public final static int REFERENCE_ACCOUNT = 175;
public final static int REFERENCE_AD_USER = 110;
public final static int REFERENCE_ASSIGNMENT = 200181;
public final static int REFERENCE_CHART = 200183;
public final static int REFERENCE_DOCUMENTACTION = 135;
public final static int REFERENCE_DOCUMENTSTATUS = 131;
public final static int REFERENCE_PAYMENTRULE = 195;
public final static int REFERENCE_POSTING_TYPE = 125;
public final static int REFERENCE_POSTED = 234;
public final static int REFERENCE_SQLORDERBY = 53296;
public final static int REFERENCE_YESNO = 319;
public final static int REFERENCE_WIZARDSTATUS = 200003;
public final static int REFERENCE_WFINSTANCE_STATE = 305;
public final static int REFERENCE_IMAGE = 200182;
public final static int REFERENCE_IMPORT_MODE = 200098;
public final static int REFERENCE_LOCATION = 133;
public final static int REFERENCE_LOCATOR = 191;
public final static int REFERENCE_PATTRIBUTE = 200180;
public final static int REFERENCE_PAYMENTRULE = 195;
public final static int REFERENCE_POSTED = 234;
public final static int REFERENCE_POSTING_TYPE = 125;
public final static int REFERENCE_SQLORDERBY = 53296;
public final static int REFERENCE_WFINSTANCE_STATE = 305;
public final static int REFERENCE_WIZARDSTATUS = 200003;
public final static int REFERENCE_YESNO = 319;
public final static int TABLE_AD_TABLE = 100;
public final static int TABLE_AD_WF_PROCESS = 645;
@ -170,11 +177,17 @@ public class SystemIDs
public final static int USER_SYSTEM = 0;
public final static int WINDOW_ACCOUNTCOMBINATION = 153;
public final static int WINDOW_ATTRIBUTESETINSTANCE = 358;
public static final int WINDOW_CHART = 53124;
public final static int WINDOW_CUSTOMERRETURN = 53097;
public final static int WINDOW_IMAGE = 227;
public final static int WINDOW_LOCATION = 121;
public final static int WINDOW_LOCATOR = 139;
public final static int WINDOW_LOT = 257;
public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223;
public final static int WINDOW_MY_REQUESTS = 237;
public final static int WINDOW_REQUESTS_ALL = 232;
public final static int WINDOW_RESOURCE = 236;
public final static int WINDOW_RETURNTOVENDOR = 53098;
public final static int WINDOW_WAREHOUSE_LOCATOR = 139;
public final static int WINDOW_WINDOW_TAB_FIELD = 102;

View File

@ -90,6 +90,7 @@ import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
import org.compiere.model.MUserQuery;
import org.compiere.model.SystemIDs;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -132,7 +133,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/**
*
*/
private static final long serialVersionUID = -3907408033854720147L;
private static final long serialVersionUID = 3968142284124286827L;
private static final String FIND_ROW_EDITOR = "find.row.editor";
@ -773,6 +774,37 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_findFields[i] = postedfield;
mField = postedfield;
}
} else if ( mField.getVO().displayType == DisplayType.Account
|| mField.getVO().displayType == DisplayType.Assignment
|| mField.getVO().displayType == DisplayType.Chart
|| mField.getVO().displayType == DisplayType.Image
|| mField.getVO().displayType == DisplayType.Location
|| mField.getVO().displayType == DisplayType.Locator
|| mField.getVO().displayType == DisplayType.PAttribute
) {
// Make special fields searchable as Search
GridFieldVO vo = mField.getVO();
GridFieldVO newvo = vo.clone(m_simpleCtx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
newvo.IsDisplayed = true;
newvo.displayType = DisplayType.Search;
switch (mField.getVO().displayType) {
case DisplayType.Account: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_ACCOUNT; break;
case DisplayType.Assignment: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_ASSIGNMENT; break;
case DisplayType.Chart: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_CHART; break;
case DisplayType.Image: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_IMAGE; break;
case DisplayType.Location: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_LOCATION; break;
case DisplayType.Locator: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_LOCATOR; break;
case DisplayType.PAttribute: newvo.AD_Reference_Value_ID = SystemIDs.REFERENCE_PATTRIBUTE; break;
}
newvo.lookupInfo = MLookupFactory.getLookupInfo (newvo.ctx, newvo.WindowNo, newvo.AD_Column_ID, newvo.displayType,
Env.getLanguage(newvo.ctx), newvo.ColumnName, newvo.AD_Reference_Value_ID,
newvo.IsParent, null);
newvo.lookupInfo.tabNo = TABNO;
GridField newfield = new GridField(newvo);
// replace the original field by the the new Search field
m_findFields[i] = newfield;
mField = newfield;
} else {
// clone the field and clean gridtab - IDEMPIERE-1105
GridField findField = (GridField) mField.clone(m_simpleCtx);
@ -842,6 +874,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
for(GridField field:gridFieldList){
if (field.isVirtualUIColumn())
continue;
if (! hasAccessSpecialFields(field))
continue;
if (!addSelectionColumn (field))
excludes.add(field);
}
@ -857,6 +891,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
for(GridField field:moreFieldList){
if (field.isVirtualUIColumn())
continue;
if (! hasAccessSpecialFields(field))
continue;
if (!addSelectionColumn (field, rowg))
excludes.add(field);
}
@ -890,7 +926,25 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/** END DEVCOFFEE **/
} // initFind
/**
private boolean hasAccessSpecialFields(GridField field) {
int windowId = 0;
switch (field.getAD_Reference_Value_ID()) {
case SystemIDs.REFERENCE_ACCOUNT: windowId = SystemIDs.WINDOW_ACCOUNTCOMBINATION; break;
case SystemIDs.REFERENCE_ASSIGNMENT: windowId = SystemIDs.WINDOW_RESOURCE; break;
case SystemIDs.REFERENCE_CHART: windowId = SystemIDs.WINDOW_CHART; break;
case SystemIDs.REFERENCE_IMAGE: windowId = SystemIDs.WINDOW_IMAGE; break;
case SystemIDs.REFERENCE_LOCATION: windowId = SystemIDs.WINDOW_LOCATION; break;
case SystemIDs.REFERENCE_LOCATOR: windowId = SystemIDs.WINDOW_LOCATOR; break;
case SystemIDs.REFERENCE_PATTRIBUTE: windowId = SystemIDs.WINDOW_ATTRIBUTESETINSTANCE; break;
}
if (windowId > 0) {
Boolean access = MRole.getDefault().getWindowAccess(windowId);
return access != null;
}
return true;
}
/**
* initialise Advanced tab
**/
private void initFindAdvanced()
@ -1119,7 +1173,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
for (int c = 0; c < m_findFields.length; c++)
{
GridField field = m_findFields[c];
if (field == null || field.isVirtualUIColumn())
if (field == null || field.isVirtualUIColumn()
|| ! hasAccessSpecialFields(field))
continue;
boolean IsLookupOnlySelection = !MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx())).isAccessAdvanced()
@ -2128,7 +2183,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
else if (DisplayType.isLookup(referenceType)
|| DisplayType.YesNo == referenceType
|| DisplayType.Button == referenceType)
|| DisplayType.Button == referenceType
|| DisplayType.Account == referenceType
|| DisplayType.Assignment == referenceType
|| DisplayType.Chart == referenceType
|| DisplayType.Image == referenceType
|| DisplayType.Location == referenceType
|| DisplayType.Locator == referenceType
|| DisplayType.PAttribute == referenceType)
{
addOperators(MQuery.OPERATORS_LOOKUP, listOperator);
}