IDEMPIERE-6255:Incorrect column count on datatables (#2483)
* IDEMPIERE-6255:Incorrect column count on datatables * IDEMPIERE-6255:Incorrect column count on datatables (csv header isn't translate) * Remove never used warning --------- Co-authored-by: hieplq <hieplq@debian.vn> Co-authored-by: hengsin <hengsin@gmail.com>
This commit is contained in:
parent
70cde611a0
commit
3512cd00da
|
@ -24,6 +24,7 @@ import java.util.Properties;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.I_AD_PrintFormatItem;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.X_AD_PrintFormatItem;
|
||||
import org.compiere.util.CCache;
|
||||
|
@ -51,18 +52,18 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem implements ImmutableP
|
|||
*/
|
||||
private static final long serialVersionUID = 2950704375830865408L;
|
||||
|
||||
/**
|
||||
* UUID based Constructor
|
||||
* @param ctx Context
|
||||
* @param AD_PrintFormatItem_UU UUID key
|
||||
* @param trxName Transaction
|
||||
*/
|
||||
public MPrintFormatItem(Properties ctx, String AD_PrintFormatItem_UU, String trxName) {
|
||||
super(ctx, AD_PrintFormatItem_UU, trxName);
|
||||
/**
|
||||
* UUID based Constructor
|
||||
* @param ctx Context
|
||||
* @param AD_PrintFormatItem_UU UUID key
|
||||
* @param trxName Transaction
|
||||
*/
|
||||
public MPrintFormatItem(Properties ctx, String AD_PrintFormatItem_UU, String trxName) {
|
||||
super(ctx, AD_PrintFormatItem_UU, trxName);
|
||||
if (Util.isEmpty(AD_PrintFormatItem_UU))
|
||||
setInitialDefaults();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param ctx context
|
||||
|
@ -179,21 +180,51 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem implements ImmutableP
|
|||
|
||||
private static CLogger s_log = CLogger.getCLogger (MPrintFormatItem.class);
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Get print name with language
|
||||
public String getPrintName (boolean useNameWhenEmpty) {
|
||||
String printName = getPrintName();
|
||||
if (Util.isEmpty(printName, true) && useNameWhenEmpty) {
|
||||
return getName();
|
||||
}
|
||||
|
||||
return printName;
|
||||
}
|
||||
/**
|
||||
* Get print name with language<br/>
|
||||
* Order of alternative values when encountering empty value<br/>
|
||||
* <ul>
|
||||
* <li>print name with language</li>
|
||||
* <li>print name</li>
|
||||
* <li>name with language</li>
|
||||
* <li>name</li>
|
||||
* </ul>
|
||||
* @param language language - ignored if IsMultiLingualDocument not 'Y'
|
||||
* @return print name
|
||||
*/
|
||||
public String getPrintName (Language language)
|
||||
{
|
||||
if (language == null || Env.isBaseLanguage(language, "AD_PrintFormatItem"))
|
||||
return getPrintName();
|
||||
return getPrintName(true);
|
||||
loadTranslations();
|
||||
String retValue = (String)m_translationLabel.get(language.getAD_Language());
|
||||
if (retValue == null || retValue.length() == 0)
|
||||
return getPrintName();
|
||||
return retValue;
|
||||
String altValue = retValue;
|
||||
|
||||
// try print name on base language
|
||||
if (Util.isEmpty(altValue, true))
|
||||
altValue = getPrintName();
|
||||
|
||||
// try translate of name
|
||||
if (Util.isEmpty(altValue, true))
|
||||
altValue = get_Translation(I_AD_PrintFormatItem.COLUMNNAME_Name, language.getAD_Language());
|
||||
|
||||
// try name on base language
|
||||
if (Util.isEmpty(altValue, true))
|
||||
altValue = getName();
|
||||
|
||||
// put value to cache
|
||||
if (Util.isEmpty(retValue, true) && !Util.isEmpty(altValue, true))
|
||||
m_translationLabel.put(language.getAD_Language(), altValue);
|
||||
|
||||
return altValue;
|
||||
} // getPrintName
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -1677,7 +1677,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
}
|
||||
columnHeader[col] = new ValueNamePair(item.getColumnName(),
|
||||
item.getPrintName(format.getLanguage()));
|
||||
colPositions.put(item.getPrintName(), col);
|
||||
colPositions.put(item.getPrintName(true), col);
|
||||
columnMaxWidth[col] = item.getMaxWidth();
|
||||
fixedWidth[col] = (columnMaxWidth[col] != 0 && item.isFixedWidth());
|
||||
colSuppressRepeats[col] = item.isSuppressRepeats();
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.File;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.window.ZkReportViewer;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.tools.FileUtil;
|
||||
|
@ -91,7 +90,7 @@ public class CSVReportViewerRenderer implements IReportViewerRenderer {
|
|||
File file = FileUtil.createTempFile(prefix, "."+getFileExtension(), new File(path));
|
||||
IReportRenderer<IReportRendererConfiguration> renderer = Core.getReportRenderer(getId());
|
||||
CSVReportRendererConfiguration config = new CSVReportRendererConfiguration()
|
||||
.setLanguage(AEnv.getLanguage(Env.getCtx()))
|
||||
.setLanguage(reportEngine.getPrintFormat().getLanguage())
|
||||
.setOutputFile(file);
|
||||
renderer.renderReport(reportEngine, config);
|
||||
return new AMedia(file.getName(), getFileExtension(), getContentType(), file, false);
|
||||
|
|
Loading…
Reference in New Issue