Use language instance instead of code for get_email

This commit is contained in:
Cédric Krier
2017-08-28 23:53:27 +02:00
parent c13814d998
commit 2c85e5c166
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -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
+3 -1
View File
@@ -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 <user@example.com>'], [], [], ['en'])
user, FROM, ['Administrator <user@example.com>'], [], [], [en])
self.assertEqual(msg['From'], FROM)
self.assertEqual(msg['Subject'], 'Notification Email')