diff options
| author | Thibault Delavallée <tde@odoo.com> | 2019-03-29 12:28:50 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-04-26 10:01:25 +0000 |
| commit | c87b351855b4e2f2c42be8a73ea468d6b1006e57 (patch) | |
| tree | ecb78354a0e9e0c9ffd2655ff1c68b089e00649c /addons/fetchmail/models | |
| parent | 01d1cf35bbbcf020d1357edbb25d5111cdd97de1 (diff) | |
[REF] fetchmail: clean and remove unnecessary code about mail.mail
Purpose: small cleaning of code linked to mail.mail model in order to
avoid unnecessary overrides
* create mail: default_fetchmail_server_id in context should be sufficient
as it is the base mechanism of default_get;
* write: unused in codebase. Anyway we should not write on mail and if it
is the case giving fetchmail_server_id directly should be the correct
way of doing it;
In case of a clean_context use we might loose default_fetchmail_server_id
key. It is used notably for tracking message generation. In that case
this information could be lost. However the whole concept of propagating
a fetrchmail_server-id from incoming mail server to outgoing emails (as
mail.mail is used only for sending email) is strange and does not require
so much specific code.
Sub-part of task 1853147 (pre-cleaning before implementing mail gateway
improvements)
Linked to PR #32974
Diffstat (limited to 'addons/fetchmail/models')
| -rw-r--r-- | addons/fetchmail/models/fetchmail.py | 2 | ||||
| -rw-r--r-- | addons/fetchmail/models/mail_mail.py | 19 |
2 files changed, 3 insertions, 18 deletions
diff --git a/addons/fetchmail/models/fetchmail.py b/addons/fetchmail/models/fetchmail.py index d04641bb450..62334f45562 100644 --- a/addons/fetchmail/models/fetchmail.py +++ b/addons/fetchmail/models/fetchmail.py @@ -160,7 +160,7 @@ class FetchmailServer(models.Model): MailThread = self.env['mail.thread'] for server in self: _logger.info('start checking for new emails on %s server %s', server.server_type, server.name) - additionnal_context['fetchmail_server_id'] = server.id + additionnal_context['default_fetchmail_server_id'] = server.id additionnal_context['server_type'] = server.server_type count, failed = 0, 0 imap_server = None diff --git a/addons/fetchmail/models/mail_mail.py b/addons/fetchmail/models/mail_mail.py index 66a9154af70..79f47d8dd12 100644 --- a/addons/fetchmail/models/mail_mail.py +++ b/addons/fetchmail/models/mail_mail.py @@ -1,25 +1,10 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import fields, models class MailMail(models.Model): - - _inherit = "mail.mail" + _inherit = 'mail.mail' fetchmail_server_id = fields.Many2one('fetchmail.server', "Inbound Mail Server", readonly=True, index=True, oldname='server_id') - - @api.model - def create(self, values): - fetchmail_server_id = self.env.context.get('fetchmail_server_id') - if fetchmail_server_id: - values['fetchmail_server_id'] = fetchmail_server_id - return super(MailMail, self).create(values) - - @api.multi - def write(self, values): - fetchmail_server_id = self.env.context.get('fetchmail_server_id') - if fetchmail_server_id: - values['fetchmail_server_id'] = fetchmail_server_id - return super(MailMail, self).write(values) |
