mirror of https://github.com/OCA/social.git
[FIX] Call to generate_email can be done with a list of ids or only one id (#65)
fixes #64pull/341/head
parent
ec7939b2d9
commit
f12d8f5275
|
@ -16,6 +16,10 @@ class MailTemplate(models.Model):
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def generate_email(self, res_ids, fields=None):
|
def generate_email(self, res_ids, fields=None):
|
||||||
|
multi_mode = True
|
||||||
|
if isinstance(res_ids, (int, long)):
|
||||||
|
res_ids = [res_ids]
|
||||||
|
multi_mode = False
|
||||||
result = super(MailTemplate, self).generate_email(
|
result = super(MailTemplate, self).generate_email(
|
||||||
res_ids, fields=fields
|
res_ids, fields=fields
|
||||||
)
|
)
|
||||||
|
@ -32,4 +36,4 @@ class MailTemplate(models.Model):
|
||||||
result[record_id]['body'] = tools.html_sanitize(
|
result[record_id]['body'] = tools.html_sanitize(
|
||||||
result[record_id]['body_html']
|
result[record_id]['body_html']
|
||||||
)
|
)
|
||||||
return result
|
return multi_mode and result or result[res_ids[0]]
|
||||||
|
|
|
@ -15,3 +15,12 @@ class TestMailTemplateQweb(TransactionCase):
|
||||||
mail_values[self.env.user.id]['body_html']
|
mail_values[self.env.user.id]['body_html']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
# the same method is also called in a non multi mode
|
||||||
|
mail_values = template.generate_email(self.env.user.id)
|
||||||
|
self.assertTrue(
|
||||||
|
# this comes from the called template if everything worked
|
||||||
|
'<footer>' in mail_values['body_html'],
|
||||||
|
'Did not rcv rendered template in response. Got: \n%s\n' % (
|
||||||
|
mail_values['body_html']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue