changeset f4e8a9e161ea in modules/account_dunning_email:default
details: 
https://hg.tryton.org/modules/account_dunning_email?cmd=changeset;node=f4e8a9e161ea
description:
        Allow distinct FROM addresses for envelope and header

        issue9948
        review324741004
diffstat:

 CHANGELOG  |  2 ++
 account.py |  9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r fd9aa0b5c86c -r f4e8a9e161ea CHANGELOG
--- a/CHANGELOG Sat Dec 19 17:08:43 2020 +0100
+++ b/CHANGELOG Wed Feb 03 23:26:07 2021 +0100
@@ -1,3 +1,5 @@
+* Allow different FROM per language
+
 Version 5.8.0 - 2020-11-02
 * Bug fixes (see mercurial logs for details)
 * Remove support for Python 3.5
diff -r fd9aa0b5c86c -r f4e8a9e161ea account.py
--- a/account.py        Sat Dec 19 17:08:43 2020 +0100
+++ b/account.py        Wed Feb 03 23:26:07 2021 +0100
@@ -39,7 +39,7 @@
             },
         depends=['send_email'])
     email_from = fields.Char(
-        "From",
+        "From", translate=True,
         states={
             'invisible': ~Eval('send_email'),
             },
@@ -114,7 +114,7 @@
 
         account_config = AccountConfig(1)
 
-        from_ = self.level.email_from or config.get('email', 'from')
+        from_ = config.get('email', 'from')
         to = []
         contact = self.party.contact_mechanism_get(
             'email', usage=self.level.email_contact_mechanism)
@@ -146,6 +146,11 @@
     def _email(self, from_, to, cc, bcc, languages):
         # TODO order languages to get default as last one for title
         msg, title = get_email(self.level.email_template, self, languages)
+        language = list(languages)[-1]
+        with Transaction().set_context(language=language.code):
+            dunning = self.__class__(self.id)
+            if dunning.level.email_from:
+                from_ = dunning.level.email_from
         msg['From'] = from_
         msg['To'] = ', '.join(to)
         msg['Cc'] = ', '.join(cc)

Reply via email to