[FIX] mass_mailing: str/bytes confusion thing

qweb returns bytes, which would be stored in a dict's `body_html`,
which would then be stringified *but not decoded*.

Running with `-b` this gets flagged, it's probably better to fill the
dict with what's actually expected (text).
This commit is contained in:
Xavier Morel
2021-04-29 05:34:21 +00:00
parent f9a1114792
commit 34fbed3639
2 changed files with 2 additions and 2 deletions
@@ -49,7 +49,7 @@ class TestMassMailValues(MassMailCommon):
})
mail_values = composer.get_mail_values([recipient.id])
body_html = str(mail_values[recipient.id]['body_html'])
body_html = mail_values[recipient.id]['body_html']
self.assertIn('<!DOCTYPE html>', body_html)
self.assertIn('<head>', body_html)
@@ -77,7 +77,7 @@ class MailComposeMessage(models.TransientModel):
'email': mail_to or mail_values.get('email_to'),
}
if mail_values.get('body_html') and mass_mail_layout:
mail_values['body_html'] = mass_mail_layout._render({'body': mail_values['body_html']}, engine='ir.qweb', minimal_qcontext=True)
mail_values['body_html'] = mass_mail_layout._render({'body': mail_values['body_html']}, engine='ir.qweb', minimal_qcontext=True).decode()
# propagate ignored state to trace when still-born
if mail_values.get('state') == 'cancel':
trace_vals['ignored'] = fields.Datetime.now()