From 5bfcedd0cacb310123d85c0c8e0cb9e679ef4a14 Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Thu, 23 Dec 2021 16:29:07 +0530 Subject: [PATCH] =?UTF-8?q?IDEMPIERE-5123:=20On=20location=20dialog=20and?= =?UTF-8?q?=20location=20Editor,=20Region=20transl=E2=80=A6=20(#1084)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * IDEMPIERE-5123: On location dialog and location Editor, Region translation is not respected. * Update MRegion.java serialVersionUID Co-authored-by: Carlos Ruiz --- .../src/org/compiere/model/MLocation.java | 14 ++++++++--- .../src/org/compiere/model/MRegion.java | 23 +++++++++++++++++-- .../webui/window/WLocationDialog.java | 4 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MLocation.java b/org.adempiere.base/src/org/compiere/model/MLocation.java index 7000f46e94..6b77214948 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MLocation.java @@ -560,7 +560,7 @@ public class MLocation extends X_C_Location implements Comparator, Immut else if (token.equals("R")) { if (getRegion() != null) // we have a region - outStr.append(getRegion().getName()); + outStr.append(getRegion().getTrlName()); else if (super.getRegionName() != null && super.getRegionName().length() > 0) outStr.append(super.getRegionName()); // local region name } @@ -585,8 +585,16 @@ public class MLocation extends X_C_Location implements Comparator, Immut // Print Region Name if entered and not part of pattern if (c.getDisplaySequence().indexOf("@R@") == -1 - && super.getRegionName() != null && super.getRegionName().length() > 0) - outStr.append(" ").append(super.getRegionName()); + && super.getRegionName() != null && super.getRegionName().length() > 0) { + + String regName =null; + if(getRegion()!=null) + regName =getRegion().getTrlName(); + else + regName =super.getRegionName(); + + outStr.append(" ").append(regName); + } String retValue = Util.replace(outStr.toString(), "\\n", "\n"); if (log.isLoggable(Level.FINEST)) log.finest("parseCRP - " + c.getDisplaySequence() + " -> " + retValue); diff --git a/org.adempiere.base/src/org/compiere/model/MRegion.java b/org.adempiere.base/src/org/compiere/model/MRegion.java index 01f508ac22..5b8728058f 100644 --- a/org.adempiere.base/src/org/compiere/model/MRegion.java +++ b/org.adempiere.base/src/org/compiere/model/MRegion.java @@ -45,7 +45,7 @@ public class MRegion extends X_C_Region /** * */ - private static final long serialVersionUID = -752467671346696325L; + private static final long serialVersionUID = 6956706379305907673L; /** * Load Regions (cached) @@ -257,9 +257,28 @@ public class MRegion extends X_C_Region */ public String toString() { - return getName(); + return getTrlName(); } // toString + /** + * Get Translated Name + * @return name + */ + public String getTrlName() + { + return getTrlName(Env.getAD_Language(Env.getCtx())); + } // getTrlName + + /** + * Get Translated Name + * @param language + * @return name + */ + public String getTrlName(String language) + { + return get_Translation(COLUMNNAME_Name, language); + } // getTrlName + /** * Compare * @param o1 object 1 diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index de86638c03..21e1d7fe5b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -192,7 +192,7 @@ public class WLocationDialog extends Window implements EventListener lstRegion.appendItem("", null); for (MRegion region : MRegion.getRegions(m_origCountry_ID)) { - lstRegion.appendItem(region.getName(),region); + lstRegion.appendItem(region.getTrlName(),region); } if (m_location.getCountry().isHasRegion()) { if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null @@ -543,7 +543,7 @@ public class WLocationDialog extends Window implements EventListener lstRegion.appendItem("", null); for (MRegion region : MRegion.getRegions(country.getC_Country_ID())) { - lstRegion.appendItem(region.getName(),region); + lstRegion.appendItem(region.getTrlName(),region); } if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0)