From ef3ed449ca1031ae4d34bd0de8faa53106b73a89 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 24 Dec 2019 00:13:21 +0100 Subject: [PATCH] IDEMPIERE-1424 Report Wizard is not using translated columns --- .../org/compiere/print/MPrintFormatItem.java | 46 +++++++++++++++++-- .../webui/panel/WRC1DisplayFieldsPanel.java | 9 ++-- .../webui/panel/WRC2FieldOrderPanel.java | 3 +- .../webui/panel/WRC3SortCriteriaPanel.java | 5 +- .../panel/WRC4GroupingCriteriaPanel.java | 3 +- .../webui/panel/WRC5SummaryFieldsPanel.java | 3 +- 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java index 8453ca0742..afd5c7b583 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java @@ -45,8 +45,7 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem /** * */ - private static final long serialVersionUID = -679302944951915141L; - + private static final long serialVersionUID = 7145503984951798641L; /** * Constructor @@ -116,6 +115,8 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem private String m_columnName = null; /** Locally cached label translations */ private HashMap m_translationLabel; + String m_newTranslationLabel = null; + boolean m_translationLabelChanged = false; /** Locally cached suffix translations */ private HashMap m_translationSuffix; @@ -138,6 +139,26 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem return retValue; } // getPrintName + /************************************************************************** + * Set print name on language + * @param language language - ignored if IsMultiLingualDocument not 'Y' + */ + public void setPrintName (Language language, String printName) + { + if (language == null || Env.isBaseLanguage(language, "AD_PrintFormatItem")) { + setPrintName(printName); + return; + } + loadTranslations(); + String retValue = (String)m_translationLabel.get(language.getAD_Language()); + if ((retValue != null && ! retValue.equals(printName)) + || (retValue == null && printName != null)) { + m_newTranslationLabel = printName; + m_translationLabelChanged = true; + m_translationLabel.put(language.getAD_Language(), printName); + } + } // getPrintName + /** * Get print name suffix with language * @param language language - ignored if IsMultiLingualDocument not 'Y' @@ -683,11 +704,30 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem + " AND AD_PrintFormatItem_Trl.AD_PrintFormatItem_ID = " + get_ID() + ")" + " AND EXISTS (SELECT * FROM AD_Client " + "WHERE AD_Client_ID=AD_PrintFormatItem_Trl.AD_Client_ID AND IsMultiLingualDocument='Y')"; - int no = DB.executeUpdate(sql, get_TrxName()); + int no = DB.executeUpdateEx(sql, get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("translations updated #" + no); } + + if (m_translationLabelChanged) { + String sql = "UPDATE AD_PrintFormatItem_Trl " + + "SET PrintName = ? " + + "WHERE AD_PrintFormatItem_ID = ?" + + " AND AD_Language=?"; + int no = DB.executeUpdateEx(sql, new Object[] {m_newTranslationLabel, get_ID(), Language.getLoginLanguage().getAD_Language()}, get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("translations updated #" + no); + + m_newTranslationLabel = null; + m_translationLabelChanged = false; + } return success; } // afterSave + @Override + public boolean is_Changed() { + if (m_translationLabelChanged) + return true; + return super.is_Changed(); + } + } // MPrintFormatItem diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java index 9fef2a3971..1d54936167 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java @@ -27,6 +27,7 @@ import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormatItem; import org.compiere.util.KeyNamePair; +import org.compiere.util.Language; import org.compiere.util.Util; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -122,7 +123,7 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener row.appendChild(m_chkboxes[i]); m_textBoxes[i] = new Textbox(); - String strValue = printItem.getPrintName(); + String strValue = printItem.getPrintName(Language.getLoginLanguage()); if(strValue ==null || strValue.length()==0){ strValue = printItem.getName(); } @@ -141,7 +142,7 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener int i=0; for (MPrintFormatItem item : m_pfi){ item.setIsActive(m_chkboxes[i].isChecked()); - item.setPrintName(m_textBoxes[i].getText()); + item.setPrintName(Language.getLoginLanguage(), m_textBoxes[i].getText()); item.saveEx(); i++; } @@ -176,8 +177,8 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener } String printname = m_textBoxes[i].getValue(); if (!Util.isEmpty(printname)) - if (! printname.equals(m_pfi.get(i).getPrintName())) - m_pfi.get(i).setPrintName(m_textBoxes[i].getValue()); + if (! printname.equals(m_pfi.get(i).getPrintName(Language.getLoginLanguage()))) + m_pfi.get(i).setPrintName(Language.getLoginLanguage(), m_textBoxes[i].getValue()); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC2FieldOrderPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC2FieldOrderPanel.java index 6c72218b5c..eb4149dfac 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC2FieldOrderPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC2FieldOrderPanel.java @@ -30,6 +30,7 @@ import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.print.MPrintFormatItem; import org.compiere.util.KeyNamePair; +import org.compiere.util.Language; import org.compiere.util.NamePair; import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.ui.event.DropEvent; @@ -207,7 +208,7 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener