details:   https://code.openbravo.com/erp/devel/pi/rev/ec94c6362d99
changeset: 31097:ec94c6362d99
user:      Naroa Iriarte <naroa.iriarte <at> openbravo.com>
date:      Thu Jan 12 17:07:55 2017 +0100
summary:   Fixed issue 34900: Email definition of the template was not 
correctly selected

If there was more than one email definition, one of them set as default, 
sometimes, when clicking the email button, the application was not choosing the 
correct email definition, which is the one with the "default" checkbox checked. 
It can happen also to have an email definition with the default checked but the 
language is different from the bussines partner's language, in this case if 
there exists another template which is not checked as default, but its language 
is the language of the business partner, this will have priority.

The problem here was that there was a piece of code which was using a Map, and 
it was overwritting the email definitions with the same language. This happened 
because the key used to store the email definitions in that map was the 
language it self. So, in the case of having, for example three email 
definitions with the same language and one of them set as default was failing 
because in the map was only stored the last one.

To fix this a new condition has been added. Now, if the email definition is 
marked as default, it is stored in the map. It does not matter to overwrite the 
other email definitions because only one can be the default and will be the one 
stored here. If the email definition is not marked as default instead, a 
comparation will be done to check if there already exists an email definition 
with the same language. If not, then, this email configuration will be added to 
the map. This is to prevent deleting the default configurations of a language.

diffstat:

 src/org/openbravo/erpCommon/utility/reporting/TemplateInfo.java |  11 ++++++---
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 4cd8e4f37081 -r ec94c6362d99 
src/org/openbravo/erpCommon/utility/reporting/TemplateInfo.java
--- a/src/org/openbravo/erpCommon/utility/reporting/TemplateInfo.java   Fri Jan 
13 11:47:44 2017 +0100
+++ b/src/org/openbravo/erpCommon/utility/reporting/TemplateInfo.java   Thu Jan 
12 17:07:55 2017 +0100
@@ -49,7 +49,7 @@
       _Body = emailDefinitionData.getField("body");
       _Language = emailDefinitionData.getField("ad_language");
       if (emailDefinitionData.getField("isdefault") != null) {
-        _IsDefault = emailDefinitionData.getField("isdefault") == "Y" ? true : 
false;
+        _IsDefault = ("Y").equals(emailDefinitionData.getField("isdefault")) ? 
true : false;
       }
       _Id = emailDefinitionData.getField("id");
     }
@@ -94,10 +94,13 @@
       if (emailDefinitionsData.length > 0) {
         for (final EmailDefinitionData emailDefinitionData : 
emailDefinitionsData) {
           final EmailDefinition emailDefinition = new 
EmailDefinition(emailDefinitionData);
-          _EmailDefinitions.put(emailDefinition.getLanguage(), 
emailDefinition);
-
-          if (emailDefinition.isDefault())
+          String language = emailDefinition.getLanguage();
+          if (emailDefinition.isDefault()) {
             _DefaultEmailDefinition = emailDefinition;
+            _EmailDefinitions.put(language, emailDefinition);
+          } else if (!_EmailDefinitions.containsKey(language)) {
+            _EmailDefinitions.put(language, emailDefinition);
+          }
         }
         if (_DefaultEmailDefinition == null && !_EmailDefinitions.isEmpty()) {
           _DefaultEmailDefinition = 
_EmailDefinitions.values().iterator().next();

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to