summaryrefslogtreecommitdiff
path: root/addons/fetchmail
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-03-13 15:44:38 +0100
committerThibault Delavallée <tde@odoo.com>2018-06-15 10:35:11 +0200
commit8c472b7b78199ad6d977cf0dca214ca916fc9e52 (patch)
tree88c3137729d8ba06440f16ed62cfcebc12482a74 /addons/fetchmail
parentb99b4e384fc0ef0f0b989bd6a347e194e6af9c64 (diff)
[REM] fetchmail: remove action_id on fetchmail
Incoming email servers have an action_id field holding a server action to run on newly created records. It comes from old implementation of mail gateways in Odoo. Since then mail gateway has evolved. Incoming mail servers are not linked to a unique model anymore. With aliases and automatic thread creation mails can create records in various models. As the server action is bound to a given model it causes issues. Either we have to give back the result of the mail gateway processing to ensure models match. Either we have to limit action_id to records created using the "default model behavior" of incoming mail servers. We choose to remove this field. Same result can be achieved with an automated action running on create trigger. If exactly the same behavior is intended the following rules should be applied * add automated action with model linked to the one you want to update depending on alias configuration and work flow; * set trigger to create; * set action as python; * if it is necessary to be linked to the mail gateway, check in record message_ids that there is a message with message_type being 'email' meaning it has received an incoming email; Using that heuristic migrating existing fetchmail action to server actions should be quite straightforward and will give more flexibility. This commit is linked to task ID 58641. Closes #23621 .
Diffstat (limited to 'addons/fetchmail')
-rw-r--r--addons/fetchmail/models/fetchmail.py13
-rw-r--r--addons/fetchmail/views/fetchmail_views.xml1
2 files changed, 0 insertions, 14 deletions
diff --git a/addons/fetchmail/models/fetchmail.py b/addons/fetchmail/models/fetchmail.py
index e03ef88ac44..270bff7730e 100644
--- a/addons/fetchmail/models/fetchmail.py
+++ b/addons/fetchmail/models/fetchmail.py
@@ -46,7 +46,6 @@ class FetchmailServer(models.Model):
date = fields.Datetime(string='Last Fetch Date', readonly=True)
user = fields.Char(string='Username', readonly=True, states={'draft': [('readonly', False)]})
password = fields.Char(readonly=True, states={'draft': [('readonly', False)]})
- action_id = fields.Many2one('ir.actions.server', string='Server Action', help="Optional custom server action to trigger for each incoming mail, on the record that was created or updated by this mail")
object_id = fields.Many2one('ir.model', string="Create a New Record", help="Process each incoming mail as part of a conversation "
"corresponding to this document type. This will create "
"new documents for new conversations, or attach follow-up "
@@ -180,12 +179,6 @@ class FetchmailServer(models.Model):
except Exception:
_logger.info('Failed to process mail from %s server %s.', server.type, server.name, exc_info=True)
failed += 1
- if res_id and server.action_id:
- server.action_id.with_context({
- 'active_id': res_id,
- 'active_ids': [res_id],
- 'active_model': self.env.context.get("thread_model", server.object_id.model)
- }).run()
imap_server.store(num, '+FLAGS', '\\Seen')
self._cr.commit()
count += 1
@@ -212,12 +205,6 @@ class FetchmailServer(models.Model):
except Exception:
_logger.info('Failed to process mail from %s server %s.', server.type, server.name, exc_info=True)
failed += 1
- if res_id and server.action_id:
- server.action_id.with_context({
- 'active_id': res_id,
- 'active_ids': [res_id],
- 'active_model': self.env.context.get("thread_model", server.object_id.model)
- }).run()
self.env.cr.commit()
if num_messages < MAX_POP_MESSAGES:
break
diff --git a/addons/fetchmail/views/fetchmail_views.xml b/addons/fetchmail/views/fetchmail_views.xml
index beb6b838c2d..9bbe6c7ea5d 100644
--- a/addons/fetchmail/views/fetchmail_views.xml
+++ b/addons/fetchmail/views/fetchmail_views.xml
@@ -48,7 +48,6 @@
</group>
<group string="Actions to Perform on Incoming Mails">
<field name="object_id"/>
- <field name="action_id" groups="base.group_no_one"/>
</group>
<group attrs="{'invisible' : [('type', '!=', 'local')]}" string="Configuration">
<field name="configuration" colspan="4"/>