IDEMPIERE-1821 print invoice sometime print nothing, because filter incorrect organization / based on patch from hieplq

This commit is contained in:
Carlos Ruiz 2015-01-07 14:12:56 -05:00
parent 27a945963f
commit fe342806ef
1 changed files with 8 additions and 2 deletions

View File

@ -33,6 +33,7 @@ import org.compiere.model.MClient;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
import org.compiere.model.MMailText; import org.compiere.model.MMailText;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.model.MUserMail; import org.compiere.model.MUserMail;
import org.compiere.model.PrintInfo; import org.compiere.model.PrintInfo;
@ -46,6 +47,7 @@ import org.compiere.util.EMail;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Language; import org.compiere.util.Language;
import org.compiere.util.Util;
/** /**
* Print Invoices on Paper or send PDFs * Print Invoices on Paper or send PDFs
@ -326,10 +328,9 @@ public class InvoicePrint extends SvrProcess
+ " INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)"
+ " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)"
+ " WHERE i.AD_Client_ID=? AND i.AD_Org_ID=? AND i.isSOTrx='Y' AND " + " WHERE i.AD_Client_ID=? AND i.isSOTrx='Y' AND "
+ " pf.AD_Org_ID IN (0,i.AD_Org_ID) " ); // more them 1 PF + " pf.AD_Org_ID IN (0,i.AD_Org_ID) " ); // more them 1 PF
params.add(Env.getAD_Client_ID(Env.getCtx())); params.add(Env.getAD_Client_ID(Env.getCtx()));
params.add(Env.getAD_Org_ID(Env.getCtx()));
if (m_C_Invoice_ID != 0) { if (m_C_Invoice_ID != 0) {
sql.append(" AND i.C_Invoice_ID=?"); sql.append(" AND i.C_Invoice_ID=?");
params.add(m_C_Invoice_ID); params.add(m_C_Invoice_ID);
@ -377,6 +378,11 @@ public class InvoicePrint extends SvrProcess
sql.append(" AND i.DocStatus IN ('CO','CL') "); sql.append(" AND i.DocStatus IN ('CO','CL') ");
} }
} }
String orgWhere = MRole.getDefault(getCtx(), false).getOrgWhere(MRole.SQL_RO);
if (!Util.isEmpty(orgWhere, true)) {
sql.append(" AND i.");
sql.append(orgWhere);
}
sql.append(" ORDER BY i.C_Invoice_ID, pf.AD_Org_ID DESC"); // more than 1 PF record sql.append(" ORDER BY i.C_Invoice_ID, pf.AD_Org_ID DESC"); // more than 1 PF record
} }