Fixed issue 37005: Error importing C_UOM translation
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Mon, 09 Oct 2017 12:39:56 +0200
changeset 32856 b29f889862c9
parent 32855 34c067c8eef2
child 32857 387066f2baf1
Fixed issue 37005: Error importing C_UOM translation

The problem was discovered when you was trying to import the es_ES translation for Core. Running install.source
task (having org.openbravo.localization.spain.referencedata.translation.esES module in the instance) some C_UOM
translations were not found. The problem was the order in wich translations were applied. (Before the import of
standard reference data).

The ApplyModule task import the data first for any translation modules. Then ApplyModule task import the reference
data modules. This order is wrong because some translations could be depend on the reference data.

Now the problem has been resolved by take into account this situation. Now, the import of the reference data are
done at first. Then the translations are applied.
src/org/openbravo/erpCommon/modules/ApplyModule.java
--- a/src/org/openbravo/erpCommon/modules/ApplyModule.java	Fri Oct 06 09:56:55 2017 +0200
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule.java	Mon Oct 09 12:39:56 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -73,13 +73,12 @@
   }
 
   /**
-   * Process the Installed but not applied modules, the treatement for these modules is: Translation
-   * modules In case the module contains translations the process will: <br/>
-   * -Sets the module language as system -Populates the trl tables calling the verify language
-   * process (this is done just once for all the modules with translations.<br/>
-   * -Imports the xml files with translations into trl tables.
-   * 
-   * Reference data modules for client system Loads the reference data in client system
+   * Process the Installed but not applied modules, the treatement for these modules is: <br/>
+   * 1.- Reference data modules for client system Loads the reference data in client system. <br/>
+   * 2.- Translation modules In case the module contains translations the process will: <br/>
+   * 2.1.- Sets the module language as system -Populates the trl tables calling the verify language
+   * process (this is done just once for all the modules with translations. <br/>
+   * 2.2.- Imports the xml files with translations into trl tables.
    * 
    * All modules Sets them as installed
    * 
@@ -91,54 +90,8 @@
       log4j.setLevel(Level.INFO);
     }
     try {
-      // **************** Translation modules ************************
-      // Check whether modules to install are translations
-      log4j.info("Looking for translation modules");
-      final ApplyModuleData[] data;
-      if (!forceRefData) {
-        data = ApplyModuleData.selectTranslationModules(pool);
-      } else {
-        data = ApplyModuleData.selectAllTranslationModules(pool);
-      }
-
-      if (data != null && data.length > 0) {
-        log4j.info(data.length + " translation modules found");
-        // Set language as system in case it is not already
-        for (int i = 0; i < data.length; i++) {
-          if (data[i].issystemlanguage.equals("N")) {
-            ApplyModuleData.setSystemLanguage(pool, data[i].adLanguage);
-          }
-        }
-
-        // Populate trl tables (execute verify languages)
-        try {
-          log4j.info("Executing verify language process");
-          final String pinstance = SequenceIdData.getUUID();
-          PInstanceProcessData.insertPInstance(pool, pinstance, "179", "0", "N", "0", "0", "0");
-
-          ApplyModuleData.process179(pool, pinstance);
-
-          final OBError myMessage = getProcessInstanceMessageSimple(pool, pinstance);
-          if (myMessage.getType().equals("Error"))
-            log4j.error(myMessage.getMessage());
-          else
-            log4j.info(myMessage.getMessage());
-        } catch (final ServletException ex) {
-          log4j.error("Error running verify language process", ex);
-        }
-
-        // Import language modules
-        for (int i = 0; i < data.length; i++) {
-          String folder = obDir + "/modules/" + data[i].javapackage + "/referencedata/translation";
-          log4j.info("Importing language " + data[i].adLanguage + " from module " + data[i].name
-              + " from folder: " + folder);
-          TranslationManager.importTrlDirectory(pool, folder, data[i].adLanguage, "0", null);
-        }
-      }
       // ************ Reference data for system client modules ************
-
       log4j.info("Looking for reference data modules");
-
       final ApplyModuleData[] ds;
       if (!forceRefData) {
         ds = ApplyModuleData.selectClientReferenceModules(pool);
@@ -195,6 +148,51 @@
         OBDal.getInstance().commitAndClose();
       }
 
+      // **************** Translation modules ************************
+      // Check whether modules to install are translations
+      log4j.info("Looking for translation modules");
+      final ApplyModuleData[] data;
+      if (!forceRefData) {
+        data = ApplyModuleData.selectTranslationModules(pool);
+      } else {
+        data = ApplyModuleData.selectAllTranslationModules(pool);
+      }
+
+      if (data != null && data.length > 0) {
+        log4j.info(data.length + " translation modules found");
+        // Set language as system in case it is not already
+        for (int i = 0; i < data.length; i++) {
+          if (data[i].issystemlanguage.equals("N")) {
+            ApplyModuleData.setSystemLanguage(pool, data[i].adLanguage);
+          }
+        }
+
+        // Populate trl tables (execute verify languages)
+        try {
+          log4j.info("Executing verify language process");
+          final String pinstance = SequenceIdData.getUUID();
+          PInstanceProcessData.insertPInstance(pool, pinstance, "179", "0", "N", "0", "0", "0");
+
+          ApplyModuleData.process179(pool, pinstance);
+
+          final OBError myMessage = getProcessInstanceMessageSimple(pool, pinstance);
+          if (myMessage.getType().equals("Error"))
+            log4j.error(myMessage.getMessage());
+          else
+            log4j.info(myMessage.getMessage());
+        } catch (final ServletException ex) {
+          log4j.error("Error running verify language process", ex);
+        }
+
+        // Import language modules
+        for (int i = 0; i < data.length; i++) {
+          String folder = obDir + "/modules/" + data[i].javapackage + "/referencedata/translation";
+          log4j.info("Importing language " + data[i].adLanguage + " from module " + data[i].name
+              + " from folder: " + folder);
+          TranslationManager.importTrlDirectory(pool, folder, data[i].adLanguage, "0", null);
+        }
+      }
+
     } catch (final OBException e) {
       throw e;
     } catch (final Exception e) {