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

        issue9948
        review324741004
diffstat:

 CHANGELOG       |   2 ++
 doc/index.rst   |  10 ++++++++++
 notification.py |  13 ++++++++-----
 3 files changed, 20 insertions(+), 5 deletions(-)

diffs (63 lines):

diff -r e5a3ed1b954a -r 551bc9402982 CHANGELOG
--- a/CHANGELOG Sat Dec 19 17:08:45 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 e5a3ed1b954a -r 551bc9402982 doc/index.rst
--- a/doc/index.rst     Sat Dec 19 17:08:45 2020 +0100
+++ b/doc/index.rst     Wed Feb 03 23:26:07 2021 +0100
@@ -4,3 +4,13 @@
 The notification email module allows to define email templates which will be
 sent to a list of recipients when a trigger is fired on a record event.
 Extra reports from the same record can be attached to the email.
+
+Configuration
+*************
+
+The notification_email module uses parameters from the section:
+
+- `[notification_email]`:
+
+    - `from`: The default `From` for the email.
+
diff -r e5a3ed1b954a -r 551bc9402982 notification.py
--- a/notification.py   Sat Dec 19 17:08:45 2020 +0100
+++ b/notification.py   Wed Feb 03 23:26:07 2021 +0100
@@ -29,7 +29,7 @@
     __name__ = 'notification.email'
 
     from_ = fields.Char(
-        "From",
+        "From", translate=True,
         help="Leave empty for the value defined in the configuration file.")
     subject = fields.Char(
         "Subject", translate=True,
@@ -176,9 +176,11 @@
         # TODO order languages to get default as last one for title
         content, title = get_email(self.content, record, languages)
         language = list(languages)[-1]
-        if self.subject:
-            with Transaction().set_context(language=language.code):
-                notification = self.__class__(self.id)
+        with Transaction().set_context(language=language.code):
+            notification = self.__class__(self.id)
+            if notification.from_:
+                from_ = notification.from_
+            if self.subject:
                 title = (TextTemplate(notification.subject)
                     .generate(record=record)
                     .render())
@@ -222,7 +224,8 @@
         Log = pool.get('notification.email.log')
         datamanager = SMTPDataManager()
         Transaction().join(datamanager)
-        from_ = self.from_ or config.get('email', 'from')
+        from_ = (config.get('notification_email', 'from')
+            or config.get('email', 'from'))
         logs = []
         for record in records:
             languagues = set()

Reply via email to