From cd69ea8f9ace289977d22077e9e24b19928b705e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 13 Mar 2018 15:53:37 +0100 Subject: [PATCH] [REM] crm, project: remove support of mail-based record update Currently crm and project parse incoming email body following an old syntax to find some "set field - value" lines in the email content. It is used to update the record linked to the discussion directly from the email. However this feature is undocumented and not really supported anymore. Moreover we don't think being able to update records from emails is a reliable way of working. Moreover those update is limited to * revenue and probably for leads; this should totally be managed from the pipeline view by lead / opportunity responsible; * priority update coming from a "priority" entry in the incoming email; this code seems strange as priority is probably not standard in email headers; * planned hours for project; this should be managed by project user and managers through dedicated views in Odoo; Let us remove that old feature and let people use desktop or mobile interface to update their records. --- addons/crm/models/crm_lead.py | 22 ---------------------- addons/project/models/project.py | 17 ----------------- odoo/tools/mail.py | 3 --- 3 files changed, 42 deletions(-) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 9fdb29a19f6..e7427f36e75 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -1173,28 +1173,6 @@ class Lead(models.Model): defaults.update(custom_values) return super(Lead, self).message_new(msg_dict, custom_values=defaults) - @api.multi - def message_update(self, msg_dict, update_vals=None): - """ Overrides mail_thread message_update that is called by the mailgateway - through message_process. - This method updates the document according to the email. - """ - if update_vals is None: - update_vals = {} - if msg_dict.get('priority') in dict(crm_stage.AVAILABLE_PRIORITIES): - update_vals['priority'] = msg_dict.get('priority') - maps = { - 'revenue': 'planned_revenue', - 'probability': 'probability', - } - for line in msg_dict.get('body', '').split('\n'): - line = line.strip() - res = tools.command_re.match(line) - if res and maps.get(res.group(1).lower()): - key = maps.get(res.group(1).lower()) - update_vals[key] = res.group(2).lower() - return super(Lead, self).message_update(msg_dict, update_vals=update_vals) - def _message_post_after_hook(self, message, values, notif_layout, notif_values): if self.email_from and not self.partner_id: # we consider that posting a message with a specified recipient (not a follower, a specific one) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 8a7ef37a487..11bb6b9314e 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -935,23 +935,6 @@ class Task(models.Model): @api.multi def message_update(self, msg, update_vals=None): """ Override to update the task according to the email. """ - if update_vals is None: - update_vals = {} - maps = { - 'cost': 'planned_hours', - } - for line in msg['body'].split('\n'): - line = line.strip() - res = tools.command_re.match(line) - if res: - match = res.group(1).lower() - field = maps.get(match) - if field: - try: - update_vals[field] = float(res.group(2).lower()) - except (ValueError, TypeError): - pass - email_list = self.email_split(msg) partner_ids = [p for p in self._find_partner_from_emails(email_list, force_create=False) if p] self.message_subscribe(partner_ids) diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index ce1ccb90e3a..0b4608c62e3 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -415,9 +415,6 @@ email_re = re.compile(r"""([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63})""", # matches a string containing only one email single_email_re = re.compile(r"""^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$""", re.VERBOSE) -# update command in emails body -command_re = re.compile("^Set-([a-z]+) *: *(.+)$", re.I + re.UNICODE) - # Updated in 7.0 to match the model name as well # Typical form of references is # group(1) = the record ID ; group(2) = the model (if any) ; group(3) = the domain