solop-develop / adempiere-grpc-server

ADempiere gRPC Server example of integration
GNU General Public License v2.0
0 stars 9 forks source link

fix: Load child records. #858

Closed EdwinBetanc0urt closed 2 months ago

EdwinBetanc0urt commented 2 months ago

SELECT R_Request.*, 
    (SELECT COALESCE(R_Resolution.Name,'') FROM R_Resolution WHERE R_Request.R_Resolution_ID=R_Resolution.R_Resolution_ID) AS "DisplayColumn_R_Resolution_ID", (SELECT COALESCE(R_Group.Name,'') FROM R_Group WHERE R_Request.R_Group_ID=R_Group.R_Group_ID) AS "DisplayColumn_R_Group_ID", SalesRep_ID_AD_User.Name AS "DisplayColumn_SalesRep_ID", (SELECT COALESCE(CAST (R_Status.SeqNo AS Text),'')||' - '||COALESCE(R_Status.Name,'') FROM R_Status WHERE R_Request.R_Status_ID=R_Status.R_Status_ID) AS "DisplayColumn_R_Status_ID", Priority_AD_Ref_List_Trl.Name AS "DisplayColumn_Priority", DueType_AD_Ref_List_Trl.Name AS "DisplayColumn_DueType", UpdatedBy_AD_User.Name AS "DisplayColumn_UpdatedBy", (SELECT COALESCE(C_BPartner.Name,'') FROM C_BPartner WHERE R_Request.C_BPartner_ID=C_BPartner.C_BPartner_ID) AS "DisplayColumn_C_BPartner_ID", (SELECT COALESCE(C_Campaign.Name,'') FROM C_Campaign WHERE R_Request.C_Campaign_ID=C_Campaign.C_Campaign_ID) AS "DisplayColumn_C_Campaign_ID", (SELECT COALESCE(C_Project.Value,'')||' - '||COALESCE(C_Project.Name,'') FROM C_Project WHERE R_Request.C_Project_ID=C_Project.C_Project_ID) AS "DisplayColumn_C_Project_ID", (SELECT COALESCE(CAST (C_ProjectPhase.SeqNo AS Text),'')||' - '||COALESCE(C_ProjectPhase.Name,'') FROM C_ProjectPhase WHERE R_Request.C_ProjectPhase_ID=C_ProjectPhase.C_ProjectPhase_ID) AS "DisplayColumn_C_ProjectPhase_ID", (SELECT COALESCE(R_RequestType.Name,'') FROM R_RequestType WHERE R_Request.R_RequestType_ID=R_RequestType.R_RequestType_ID) AS "DisplayColumn_R_RequestType_ID", CreatedBy_AD_User.Name AS "DisplayColumn_CreatedBy", (SELECT COALESCE(AD_Org.Name,'') FROM AD_Org WHERE R_Request.AD_Org_ID=AD_Org.AD_Org_ID) AS "DisplayColumn_AD_Org_ID", User1_ID_C_ElementValue_Trl.Name AS "DisplayColumn_User1_ID", 
    (SELECT COALESCE(R_Request.DocumentNo,'') FROM R_Request AS R_Request_R_Request_ID WHERE R_Request_R_Request_ID.R_Request_ID=R_Request.R_Request_ID) AS "DisplayColumn_R_Request_ID" 

FROM R_Request AS R_Request 

LEFT JOIN AD_User AS SalesRep_ID_AD_User ON(SalesRep_ID_AD_User.AD_User_ID = R_Request.SalesRep_ID) 

LEFT JOIN AD_Ref_List AS Priority_AD_Ref_List ON(Priority_AD_Ref_List.Value = R_Request.Priority AND Priority_AD_Ref_List.AD_Reference_ID = 154) 

LEFT JOIN AD_Ref_List_Trl AS Priority_AD_Ref_List_Trl ON(Priority_AD_Ref_List_Trl.AD_Ref_List_ID = Priority_AD_Ref_List.AD_Ref_List_ID AND Priority_AD_Ref_List_Trl.AD_Language = 'es_MX') 

LEFT JOIN AD_Ref_List AS DueType_AD_Ref_List ON(DueType_AD_Ref_List.Value = R_Request.DueType AND DueType_AD_Ref_List.AD_Reference_ID = 222) 

LEFT JOIN AD_Ref_List_Trl AS DueType_AD_Ref_List_Trl ON(DueType_AD_Ref_List_Trl.AD_Ref_List_ID = DueType_AD_Ref_List.AD_Ref_List_ID AND DueType_AD_Ref_List_Trl.AD_Language = 'es_MX') 

LEFT JOIN AD_User AS UpdatedBy_AD_User ON(UpdatedBy_AD_User.AD_User_ID = R_Request.UpdatedBy) 

LEFT JOIN AD_User AS CreatedBy_AD_User ON(CreatedBy_AD_User.AD_User_ID = R_Request.CreatedBy) 

LEFT JOIN C_ElementValue AS User1_ID_C_ElementValue ON(User1_ID_C_ElementValue.C_ElementValue_ID = R_Request.User1_ID) 

LEFT JOIN C_ElementValue_Trl AS User1_ID_C_ElementValue_Trl ON(User1_ID_C_ElementValue_Trl.C_ElementValue_ID = User1_ID_C_ElementValue.C_ElementValue_ID AND User1_ID_C_ElementValue_Trl.AD_Language = 'es_MX') 

WHERE 
    R_Request.AD_Client_ID IN(0,1000001) 
    AND R_Request.AD_Org_ID IN(0,1000003,1000004,1000005,1000006,1000010,1000001,1000002,1000007,1000008,1000009) 
    AND (R_Request.R_Request_ID IS NULL OR R_Request.R_Request_ID NOT IN ( SELECT Record_ID FROM AD_Private_Access WHERE AD_Table_ID = 417 AND AD_User_ID <> 1001212 AND IsActive = 'Y' )) 
    AND EXISTS(
        SELECT 1 FROM C_Project AS t0 
            WHERE 1=1
            AND t0.R_RequestUpdate_ID = -1 
            AND t0.C_Project_ID = R_Request.C_Project_ID
    )

After this changes

imagen

imagen

WHERE 
    R_Request.AD_Client_ID IN(0,1000001) 
    AND R_Request.AD_Org_ID IN(0,1000003,1000004,1000005,1000006,1000010,1000001,1000002,1000007,1000008,1000009) 
    AND (R_Request.R_Request_ID IS NULL OR R_Request.R_Request_ID NOT IN ( SELECT Record_ID FROM AD_Private_Access WHERE AD_Table_ID = 417 AND AD_User_ID <> 1001212 AND IsActive = 'Y' )) 
    AND R_Request.C_Project_ID = 1007811