From 2c85e5c166c3885deee9dda734ab9efbbfe7adb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 28 Aug 2017 23:53:27 +0200 Subject: [PATCH] Use language instance instead of code for get_email --- notification.py | 2 +- tests/test_notification_email.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/notification.py b/notification.py index 50ce41736e..ec536c254c 100644 --- a/notification.py +++ b/notification.py @@ -166,7 +166,7 @@ class Email(ModelSQL, ModelView): msg.attach(content) language = list(languages)[-1] for report in self.attachments: - msg.attach(Attachment.get_mime(report, record, language)) + msg.attach(Attachment.get_mime(report, record, language.code)) else: msg = content diff --git a/tests/test_notification_email.py b/tests/test_notification_email.py index 6b9fc4f2d9..04796311a8 100644 --- a/tests/test_notification_email.py +++ b/tests/test_notification_email.py @@ -115,6 +115,7 @@ class NotificationEmailTestCase(ModuleTestCase): Report = pool.get('ir.action.report') User = pool.get('res.user') NotificationEmail = pool.get('notification.email') + Language = pool.get('ir.lang') model, = Model.search([ ('model', '=', User.__name__), @@ -122,6 +123,7 @@ class NotificationEmailTestCase(ModuleTestCase): action_model, = Model.search([ ('model', '=', 'notification.email'), ]) + en, = Language.search([('code', '=', 'en')]) action = Action(name="Notification Email", type='ir.action.report') action.save() @@ -157,7 +159,7 @@ class NotificationEmailTestCase(ModuleTestCase): user, = User.create([{'name': "Michael Scott", 'login': "msc"}]) msg = notification_email.get_email( - user, FROM, ['Administrator '], [], [], ['en']) + user, FROM, ['Administrator '], [], [], [en]) self.assertEqual(msg['From'], FROM) self.assertEqual(msg['Subject'], 'Notification Email')