[REF] l10n_it_edi, website_forum: give email_from / author when creating messages and mails

Purpose: clean mail.mail creation code and use standard mail creation or
template send_mail method. In those addons we ensure author and email_from
are set to maching values, leading to more consistent emails.

Related task ID 1965040
PR #32459

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Thibault Delavallée
2019-04-05 14:05:31 +00:00
parent ea3f4690aa
commit 0b47b2f22c
2 changed files with 4 additions and 1 deletions
@@ -272,6 +272,7 @@ class AccountInvoice(models.Model):
message = self.env['mail.message'].create({
'subject': _('Sending file: %s') % (self.l10n_it_einvoice_id.name),
'body': _('Sending file: %s to ES: %s') % (self.l10n_it_einvoice_id.name, self.env.user.company_id.l10n_it_address_recipient_fatturapa),
'author_id': self.env.user.partner_id.id,
'email_from': self.env.user.company_id.l10n_it_address_send_fatturapa,
'mail_server_id': self.env.user.company_id.l10n_it_mail_pec_server_id.id,
'attachment_ids': [(6, 0, self.l10n_it_einvoice_id.ids)],
+3 -1
View File
@@ -685,8 +685,10 @@ class Post(models.Model):
# post the message
question = self.parent_id
self_sudo = self.sudo()
values = {
'author_id': self.sudo().create_uid.partner_id.id, # use sudo here because of access to res.users model
'author_id': self_sudo.create_uid.partner_id.id, # use sudo here because of access to res.users model
'email_from': self_sudo.create_uid.email_formatted, # use sudo here because of access to res.users model
'body': tools.html_sanitize(self.content, sanitize_attributes=True, strip_style=True, strip_classes=True),
'message_type': 'comment',
'subtype': 'mail.mt_comment',