hg merge release-7.1 (merge release7.1 into default)

This commit is contained in:
Carlos Ruiz 2019-11-30 15:17:26 +01:00
commit 703ce023f9
13 changed files with 180 additions and 46 deletions

View File

@ -796,7 +796,7 @@ public class MColumn extends X_AD_Column
int refid = getAD_Reference_ID();
if (DisplayType.TableDir == refid || (DisplayType.Search == refid && getAD_Reference_Value_ID() == 0)) {
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
} else if (DisplayType.Table == refid || DisplayType.Search == refid) {
} else if (DisplayType.Table == refid || DisplayType.Search == refid) {
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID());
if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
@ -806,7 +806,13 @@ public class MColumn extends X_AD_Column
foreignTable = rt.getAD_Table().getTableName();
}
}
} else if (DisplayType.List == refid || DisplayType.Payment == refid) {
} else if (DisplayType.Button == refid) {
// C_BPartner.AD_OrgBP_ID and C_Project.C_ProjectType_ID are defined as buttons
if ("AD_OrgBP_ID".equalsIgnoreCase(getColumnName()))
foreignTable = "AD_Org";
else if ("C_ProjectType_ID".equalsIgnoreCase(getColumnName()))
foreignTable = "C_ProjectType";
} else if (DisplayType.List == refid || DisplayType.Payment == refid) {
foreignTable = "AD_Ref_List";
} else if (DisplayType.Location == refid) {
foreignTable = "C_Location";

View File

@ -367,10 +367,13 @@ public class MInOut extends X_M_InOut implements DocAction
//
setM_Warehouse_ID (order.getM_Warehouse_ID());
setIsSOTrx (order.isSOTrx());
if (C_DocTypeShipment_ID == 0)
C_DocTypeShipment_ID = DB.getSQLValue(null,
"SELECT C_DocTypeShipment_ID FROM C_DocType WHERE C_DocType_ID=?",
order.getC_DocType_ID());
if (C_DocTypeShipment_ID == 0) {
MDocType dto = MDocType.get(getCtx(), order.getC_DocType_ID());
C_DocTypeShipment_ID = dto.getC_DocTypeShipment_ID();
if (C_DocTypeShipment_ID <= 0)
throw new AdempiereException("@NotFound@ @C_DocTypeShipment_ID@ - @C_DocType_ID@:"
+dto.get_Translation(MDocType.COLUMNNAME_Name));
}
setC_DocType_ID (C_DocTypeShipment_ID);
// patch suggested by Armen

View File

@ -305,6 +305,9 @@ public class MJournalLine extends X_GL_JournalLine
fillDimensionsFromCombination();
// end idempiere 344 - nmicoud
if (getLine() == 0)
setLine(DB.getSQLValueEx(get_TrxName(), "SELECT COALESCE(MAX(Line), 0) + 10 FROM GL_JournalLine WHERE GL_Journal_ID = ?", getGL_Journal_ID()));
// Acct Amts
BigDecimal rate = getCurrencyRate();
BigDecimal amt = rate.multiply(getAmtSourceDr());

View File

@ -687,8 +687,20 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
if (doc != null)
{
appendInlineCss(doc);
//IDEMPIERE-4113
mapCssInfo.clear();
MPrintFormatItem item = null;
int printColIndex = -1;
for(int col = 0; col < m_printFormat.getItemCount(); col++)
{
item = m_printFormat.getItem(col);
if(item.isPrinted())
{
printColIndex++;
addCssInfo(item, printColIndex);
}
}//IDEMPIERE-4113
appendInlineCss(doc);
StringBuilder styleBuild = new StringBuilder();
MPrintTableFormat tf = m_printFormat.getTableFormat();
@ -920,11 +932,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
td.setClass(cssPrefix + "-date");
else
td.setClass(cssPrefix + "-text");
}
//just run with on record
if (row == 0)
addCssInfo(item, printColIndex);
}
}
else if (obj instanceof PrintData)
{

View File

@ -183,17 +183,32 @@ public class PoFiller{
}
if (po.get_ColumnIndex(columnName) >= 0) {
MColumn col = MColumn.get(ctx.ctx, po.get_TableName(), columnName);
MTable foreignTable = null;
String refTableName = col.getReferenceTableName();
if (id > 0) {
MTable foreignTable = MTable.get(Env.getCtx(), refTableName);
PO subPo = foreignTable.getPO(id, po.get_TrxName());
if (subPo.getAD_Client_ID() != Env.getAD_Client_ID(ctx.ctx)) {
String accessLevel = foreignTable.getAccessLevel();
if ((MTable.ACCESSLEVEL_All.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemOnly.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemPlusClient.equals(accessLevel)) &&
subPo.getAD_Client_ID() != 0)
return -1;
if (refTableName != null) {
foreignTable = MTable.get(Env.getCtx(), refTableName);
} else {
if ("Record_ID".equalsIgnoreCase(columnName)) {
// special case - get the foreign table using column AD_Table_ID
int idxTableID = po.get_ColumnIndex("AD_Table_ID");
if (idxTableID >= 0) {
int tableID = po.get_ValueAsInt(idxTableID);
foreignTable = MTable.get(Env.getCtx(), tableID);
refTableName = foreignTable.getTableName();
}
}
}
if (id > 0 && refTableName != null) {
if (foreignTable != null) {
PO subPo = foreignTable.getPO(id, po.get_TrxName());
if (subPo != null && subPo.getAD_Client_ID() != Env.getAD_Client_ID(ctx.ctx)) {
String accessLevel = foreignTable.getAccessLevel();
if ((MTable.ACCESSLEVEL_All.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemOnly.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemPlusClient.equals(accessLevel)) &&
subPo.getAD_Client_ID() != 0)
return -1;
}
}
if (po.get_ValueAsInt(columnName) != id) {

View File

@ -18,13 +18,14 @@ import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import org.compiere.db.CConnection;
import org.compiere.model.PrintInfo;
public class JasperViewer extends javax.swing.JFrame {
private static final long serialVersionUID = 1192807883081180999L;
private String m_title;
private PrintInfo m_printInfo;
/** Creates new form JasperViewer */
/**
@ -32,11 +33,12 @@ public class JasperViewer extends javax.swing.JFrame {
* @param frameTitle Title to be displayed
* @throws JRException
*/
protected JasperViewer(JasperPrint jasperPrint,String frameTitle) throws JRException {
protected JasperViewer(JasperPrint jasperPrint,String frameTitle, PrintInfo printInfo) throws JRException {
this.m_title = frameTitle;
initComponents();
JasperReportViewer viewer = new JasperReportViewer(this, jasperPrint);
this.pnlMain.add(viewer, BorderLayout.CENTER);
m_printInfo = printInfo;
}
@ -85,12 +87,12 @@ public class JasperViewer extends javax.swing.JFrame {
/**
*
*/
public static void viewReport(JasperPrint jasperPrint) throws JRException {
JasperViewer jasperViewer = new JasperViewer(jasperPrint,"JasperReport");
public static void viewReport(JasperPrint jasperPrint, PrintInfo printInfo) throws JRException {
JasperViewer jasperViewer = new JasperViewer(jasperPrint,"JasperReport", printInfo);
jasperViewer.setVisible(true);
}
public static void viewReport(JasperPrint jasperPrint,String frameTitle) throws JRException {
JasperViewer jasperViewer = new JasperViewer(jasperPrint,frameTitle);
public static void viewReport(JasperPrint jasperPrint,String frameTitle, PrintInfo printInfo) throws JRException {
JasperViewer jasperViewer = new JasperViewer(jasperPrint,frameTitle, printInfo);
jasperViewer.setVisible(true);
}
@ -105,7 +107,7 @@ public class JasperViewer extends javax.swing.JFrame {
try {
JasperReport myjasperReport = (JasperReport) JasperCompileManager.compileReport(args[0] );
JasperPrint myjasperPrint = JasperFillManager.fillReport( myjasperReport, new HashMap<String,Object>(), getConnection());
JasperViewer.viewReport(myjasperPrint);
JasperViewer.viewReport(myjasperPrint, null);
}
catch (Exception e) {
e.printStackTrace();

View File

@ -1,14 +1,15 @@
package org.compiere.report;
import org.adempiere.report.jasper.JRViewerProvider;
import org.compiere.model.PrintInfo;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
public class SwingJRViewerProvider implements JRViewerProvider {
public void openViewer(JasperPrint jasperPrint, String title) throws JRException {
JasperViewer jasperViewer = new JasperViewer( jasperPrint, title);
public void openViewer(JasperPrint jasperPrint, String title, PrintInfo printInfo) throws JRException {
JasperViewer jasperViewer = new JasperViewer( jasperPrint, title, printInfo);
jasperViewer.setExtendedState(jasperViewer.getExtendedState() | javax.swing.JFrame.MAXIMIZED_BOTH);
jasperViewer.setVisible(true);
}

View File

@ -1,9 +1,16 @@
package org.adempiere.report.jasper;
import org.compiere.model.PrintInfo;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
public interface JRViewerProvider {
public void openViewer(JasperPrint jasperPrint, String title) throws JRException;
public void openViewer(JasperPrint jasperPrint, String title, PrintInfo printInfo) throws JRException;
default void openViewer(JasperPrint jasperPrint, String title) throws JRException {
openViewer(jasperPrint, title, null);
}
}

View File

@ -2,10 +2,17 @@ package org.adempiere.report.jasper;
import java.util.List;
import org.compiere.model.PrintInfo;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
public interface JRViewerProviderList {
public void openViewer(List<JasperPrint> jasperPrintList, String title) throws JRException;
public void openViewer(List<JasperPrint> jasperPrintList, String title, PrintInfo printInfo) throws JRException;
default void openViewer(List<JasperPrint> jasperPrintList, String title) throws JRException {
openViewer(jasperPrintList, title, null);
}
}

View File

@ -722,13 +722,15 @@ public class ReportStarter implements ProcessCall, ClientProcess
}
}
} else {
if (reportPathList.length == 1) {
if (printInfo == null)
printInfo = new PrintInfo(pi);
if (reportPathList.length == 1) {
if (log.isLoggable(Level.INFO)) log.info( "ReportStarter.startProcess run report -"+jasperPrint.getName());
JRViewerProvider viewerLauncher = Service.locator().locate(JRViewerProvider.class).getService();
if (!Util.isEmpty(processInfo.getReportType())) {
jasperPrint.setProperty("IDEMPIERE_REPORT_TYPE", processInfo.getReportType());
}
viewerLauncher.openViewer(jasperPrint, pi.getTitle());
viewerLauncher.openViewer(jasperPrint, pi.getTitle(), printInfo);
} else {
jasperPrintList.add(jasperPrint);
if (idx+1 == reportPathList.length) {
@ -736,7 +738,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
if (viewerLauncher == null) {
throw new AdempiereException("Can not find a viewer provider for multiple jaspers");
}
viewerLauncher.openViewer(jasperPrintList, pi.getTitle());
viewerLauncher.openViewer(jasperPrintList, pi.getTitle(), printInfo);
}
}
}

View File

@ -1342,7 +1342,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment());
toolbar.getButton("PostIt").setPressed(adTabbox.getSelectedGridTab().hasPostIt());
toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat());
toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive());
if (toolbar.isPersonalLock)
{
@ -1361,6 +1360,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enableProcessButton(!isNewRow && adtab != null && adtab.getToolbarButtons().size() > 0);
toolbar.enableCustomize(adtab.isGridView());
}
toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive() ||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
}
@ -1707,8 +1709,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enablePostIt(false);
}
toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive());
// Elaine 2008/12/05
// Lock Indicator
if (toolbar.isPersonalLock)
@ -1727,7 +1727,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enableZoomAcross(!isNewRow);
toolbar.enableActiveWorkflows(!isNewRow);
toolbar.enableRequests(!isNewRow);
toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive() ||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted() && !isNewRow);
toolbar.enableReport(!isNewRow);
toolbar.enableExport(!isNewRow && !adTabbox.getSelectedGridTab().isSortTab());

View File

@ -1,6 +1,8 @@
package org.adempiere.webui.window;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@ -21,9 +23,11 @@ import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MArchive;
import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MUser;
import org.compiere.model.PrintInfo;
import org.compiere.tools.FileUtil;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
@ -91,10 +95,12 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
private KeyEvent prevKeyEvent;
private String m_title; // local title - embedded windows clear the title
protected ToolBarButton bArchive = new ToolBarButton();
private PrintInfo m_printInfo;
private int mediaVersion = 0;
public ZkJRViewer(JasperPrint jasperPrint, String title) {
public ZkJRViewer(JasperPrint jasperPrint, String title, PrintInfo printInfo) {
super();
this.setTitle(title);
m_title = title;
@ -102,10 +108,11 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
this.isList = false;
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo);
m_printInfo = printInfo;
init();
}
public ZkJRViewer(java.util.List<JasperPrint> jasperPrintList, String title) {
public ZkJRViewer(java.util.List<JasperPrint> jasperPrintList, String title, PrintInfo printInfo) {
super();
this.setTitle(title);
m_title = title;
@ -113,6 +120,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
this.isList = true;
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo);
m_printInfo = printInfo;
init();
}
@ -202,6 +210,16 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
bSendMail.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "SendMail")));
toolbar.appendChild(bSendMail);
bSendMail.addEventListener(Events.ON_CLICK, this);
toolbar.appendChild(new Separator("vertical"));
bArchive.setName("Archive");
if (ThemeManager.isUseFontIconForImage())
bArchive.setIconSclass("z-icon-Archive");
else
bArchive.setImage(ThemeManager.getThemeResource("images/Archive24.png"));
bArchive.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Archive")));
toolbar.appendChild(bArchive);
bArchive.addEventListener(Events.ON_CLICK, this);
North north = new North();
layout.appendChild(north);
@ -251,6 +269,8 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
cmd_render();
else if (e.getTarget() == bSendMail) // Added by Martin Augustine - Ntier software services 09/10/2013
cmd_sendMail();
else if (e.getTarget() == bArchive)
cmd_archive();
} // actionPerformed
private void cmd_render() {
@ -524,5 +544,62 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
return media;
}
}
/**
* Create archive for jasper report
*/
protected void cmd_archive()
{
boolean success = false;
try
{
byte[] data = getFileByteData(getPDF());
if (data != null && m_printInfo != null)
{
MArchive archive = new MArchive(Env.getCtx(), m_printInfo, null);
archive.setBinaryData(data);
success = archive.save();
}
if (success)
FDialog.info(m_WindowNo, this, "Archived");
else
FDialog.error(m_WindowNo, this, "ArchiveError");
}
catch (IOException e)
{
log.log(Level.SEVERE, "Exception while reading file " + e);
}
catch (JRException e)
{
log.log(Level.SEVERE, "Error loading object from InputStream" + e);
}
} // cmd_archive
/**
* convert File data into Byte Data
* @param tempFile
* @return file in ByteData
*/
private byte[] getFileByteData(File tempFile)
{
byte fileContent[] = new byte[(int) tempFile.length()];
try
{
FileInputStream fis = new FileInputStream(tempFile);
fis.read(fileContent);
fis.close();
}
catch (FileNotFoundException e)
{
log.log(Level.SEVERE, "File not found " + e);
}
catch (IOException ioe)
{
log.log(Level.SEVERE, "Exception while reading file " + ioe);
}
return fileContent;
} // getFileByteData
}

View File

@ -8,19 +8,20 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager;
import org.compiere.model.PrintInfo;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
public class ZkJRViewerProvider implements JRViewerProvider, JRViewerProviderList {
public void openViewer(final JasperPrint jasperPrint, final String title)
public void openViewer(final JasperPrint jasperPrint, final String title, final PrintInfo printInfo)
throws JRException {
Runnable runnable = new Runnable() {
@Override
public void run() {
Window viewer = new ZkJRViewer(jasperPrint, title);
Window viewer = new ZkJRViewer(jasperPrint, title, printInfo);
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
@ -31,13 +32,13 @@ public class ZkJRViewerProvider implements JRViewerProvider, JRViewerProviderLis
AEnv.executeAsyncDesktopTask(runnable);
}
public void openViewer(final List<JasperPrint> jasperPrintList, final String title)
public void openViewer(final List<JasperPrint> jasperPrintList, final String title , final PrintInfo printInfo)
throws JRException {
Runnable runnable = new Runnable() {
@Override
public void run() {
Window viewer = new ZkJRViewer(jasperPrintList, title);
Window viewer = new ZkJRViewer(jasperPrintList, title, printInfo);
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);