IDEMPIERE-5217 : Default values in mail templates (#1218)

This commit is contained in:
Nicolas Micoud 2022-03-03 14:54:32 +01:00 committed by GitHub
parent 32f26f8752
commit 673db27766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -214,6 +214,13 @@ public class MMailText extends X_R_MailText
if (variable.contains("<") && variable.contains(">")) { // IDEMPIERE-3096
return Env.parseVariable("@"+variable+"@", po, get_TrxName(), true);
}
String defaultValue = "";
if (variable.contains(":")) {
defaultValue = variable.substring(variable.indexOf(":") + 1, variable.length());
variable = variable.substring(0, variable.indexOf(":"));
}
// special default formatting cases for dates/times/boolean in mail text not covered by Env.parseVariable
int index = po.get_ColumnIndex(variable);
if (index == -1){
@ -237,7 +244,7 @@ public class MMailText extends X_R_MailText
value = po.get_Value(index);
}
if (value == null)
return "";
return defaultValue;
return value.toString();
} // translate

View File

@ -1671,6 +1671,13 @@ public final class Env
token = inStr.substring(0, j);
String defaultValue = "";
int idx = token.indexOf(":");
if (token.contains(":")) {
defaultValue = token.substring(token.indexOf(":") + 1, token.length());
token = token.substring(0, idx);
}
//format string
String format = "";
int f = token.indexOf('<');
@ -1757,6 +1764,8 @@ public final class Env
outStr.append(v.toString());
}
}
else if (!Util.isEmpty(defaultValue))
outStr.append(defaultValue);
} else if (keepUnparseable) {
outStr.append("@").append(token);
if (!Util.isEmpty(format))