[FIX] mail: mail_server_id
When a specific SMTP server is set on a mail template, it is never used when the mail is sent. There are two reasons: - `mail_server_id` is a read-only field set by an onchange. However, a read-only field is not sent to the server, so the information is lost. - The information is stored in the context of the object `Mail`, but it is never used. Moreover, when the method `message_post` is called, the `Mail` object is not used to post the message, so the information is lost again. The fix includes two parts: - the `mail_server_id` field is not read-only anymore. Actually, there is no reason to make it read-only. - the information is stored directly in the mail values and used at the appropriate moment. Fixes #6554 (from v9.0) opw-669958
This commit is contained in:
@@ -110,7 +110,7 @@ class Message(models.Model):
|
||||
help='Answers do not go in the original document discussion thread. This has an impact on the generated message-id.')
|
||||
message_id = fields.Char('Message-Id', help='Message unique identifier', select=1, readonly=1, copy=False)
|
||||
reply_to = fields.Char('Reply-To', help='Reply email address. Setting the reply_to bypasses the automatic thread creation.')
|
||||
mail_server_id = fields.Many2one('ir.mail_server', 'Outgoing mail server', readonly=1)
|
||||
mail_server_id = fields.Many2one('ir.mail_server', 'Outgoing mail server')
|
||||
|
||||
@api.multi
|
||||
def _get_needaction(self):
|
||||
|
||||
@@ -93,6 +93,7 @@ class Partner(models.Model):
|
||||
|
||||
mail_values = {
|
||||
'mail_message_id': message.id,
|
||||
'mail_server_id': message.mail_server_id.id,
|
||||
'auto_delete': self._context.get('mail_auto_delete', True),
|
||||
'references': references,
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ class MailComposer(models.TransientModel):
|
||||
if wizard.template_id:
|
||||
# template user_signature is added when generating body_html
|
||||
# mass mailing: use template auto_delete value -> note, for emails mass mailing only
|
||||
Mail = Mail.with_context(mail_notify_user_signature=False, mail_server_id=wizard.template_id.mail_server_id.id)
|
||||
Mail = Mail.with_context(mail_notify_user_signature=False)
|
||||
ActiveModel = ActiveModel.with_context(mail_notify_user_signature=False, mail_auto_delete=wizard.template_id.auto_delete)
|
||||
if not hasattr(ActiveModel, 'message_post'):
|
||||
ActiveModel = self.env['mail.thread'].with_context(thread_model=wizard.model)
|
||||
@@ -282,6 +282,7 @@ class MailComposer(models.TransientModel):
|
||||
'email_from': self.email_from,
|
||||
'record_name': self.record_name,
|
||||
'no_auto_thread': self.no_auto_thread,
|
||||
'mail_server_id': self.mail_server_id.id,
|
||||
}
|
||||
# mass mailing: rendering override wizard static values
|
||||
if mass_mail_mode and self.model:
|
||||
|
||||
Reference in New Issue
Block a user