[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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 <timestamp-openerp-record_id-model_name@domain>
|
||||
# group(1) = the record ID ; group(2) = the model (if any) ; group(3) = the domain
|
||||
|
||||
Reference in New Issue
Block a user