[FIX] hr_recruitment: avoid overriding email_from and email_cc in

message_update. This behavior makes sens only in message_new when
setting initial parameter of the applicant, not when somebody sends
an email on the record.
Removed priority change when there is  a 'priority' key in msg; but
this key is not likely to be present in a parsed email.
Removed updated values change due to a mapping of values present in
the email. This code was a copy-and-paste from crm and did not have
any meaning in hr_recruitment.

Also removed unnecessary code in project, project_issue, crm_helpdesk
and crm_claim for the same reasons as for hr_recruitment.

bzr revid: tde@openerp.com-20131104092731-ixasweoy1dbllbb3
This commit is contained in:
Thibault Delavallée 2013-11-04 10:27:31 +01:00
parent 06c8267768
commit 9537e55894
5 changed files with 20 additions and 132 deletions

View File

@ -188,7 +188,8 @@ class crm_claim(base_stage, osv.osv):
through message_process.
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
if custom_values is None:
custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
defaults = {
'name': msg.get('subject') or _("No Subject"),
@ -200,33 +201,7 @@ class crm_claim(base_stage, osv.osv):
if msg.get('priority'):
defaults['priority'] = msg.get('priority')
defaults.update(custom_values)
return super(crm_claim,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
def message_update(self, cr, uid, ids, msg, update_vals=None, context=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 isinstance(ids, (str, int, long)):
ids = [ids]
if update_vals is None: update_vals = {}
if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES):
update_vals['priority'] = msg.get('priority')
maps = {
'cost':'planned_cost',
'revenue': 'planned_revenue',
'probability':'probability'
}
for line in msg['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(crm_claim,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
return super(crm_claim, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
class res_partner(osv.osv):
_inherit = 'res.partner'

View File

@ -98,7 +98,8 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
through message_process.
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
if custom_values is None:
custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
defaults = {
'name': msg.get('subject') or _("No Subject"),
@ -109,32 +110,6 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
'partner_id': msg.get('author_id', False),
}
defaults.update(custom_values)
return super(crm_helpdesk,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
def message_update(self, cr, uid, ids, msg, update_vals=None, context=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 isinstance(ids, (str, int, long)):
ids = [ids]
if update_vals is None: update_vals = {}
if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES):
update_vals['priority'] = msg.get('priority')
maps = {
'cost':'planned_cost',
'revenue': 'planned_revenue',
'probability':'probability'
}
for line in msg['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(crm_helpdesk,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
return super(crm_helpdesk, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -352,7 +352,8 @@ class hr_applicant(base_stage, osv.Model):
through message_process.
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
if custom_values is None:
custom_values = {}
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
defaults = {
'name': msg.get('subject') or _("No Subject"),
@ -365,38 +366,7 @@ class hr_applicant(base_stage, osv.Model):
if msg.get('priority'):
defaults['priority'] = msg.get('priority')
defaults.update(custom_values)
return super(hr_applicant,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
""" Override mail_thread message_update that is called by the mailgateway
through message_process.
This method updates the document according to the email.
"""
if isinstance(ids, (str, int, long)):
ids = [ids]
if update_vals is None:
update_vals = {}
update_vals.update({
'email_from': msg.get('from'),
'email_cc': msg.get('cc'),
})
if msg.get('priority'):
update_vals['priority'] = msg.get('priority')
maps = {
'cost': 'planned_cost',
'revenue': 'planned_revenue',
'probability': 'probability',
}
for line in msg.get('body', '').split('\n'):
line = line.strip()
res = tools.command_re.match(line)
if res and maps.get(res.group(1).lower(), False):
key = maps.get(res.group(1).lower())
update_vals[key] = res.group(2).lower()
return super(hr_applicant, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
return super(hr_applicant, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
def create(self, cr, uid, vals, context=None):
if context is None:

View File

@ -1206,20 +1206,21 @@ class task(base_stage, osv.osv):
def message_new(self, cr, uid, msg, custom_values=None, context=None):
""" Override to updates the document according to the email. """
if custom_values is None: custom_values = {}
if custom_values is None:
custom_values = {}
defaults = {
'name': msg.get('subject'),
'planned_hours': 0.0,
}
defaults.update(custom_values)
return super(task,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
return super(task, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
""" Override to update the task according to the email. """
if update_vals is None: update_vals = {}
act = False
if update_vals is None:
update_vals = {}
maps = {
'cost':'planned_hours',
'cost': 'planned_hours',
}
for line in msg['body'].split('\n'):
line = line.strip()
@ -1232,12 +1233,7 @@ class task(base_stage, osv.osv):
update_vals[field] = float(res.group(2).lower())
except (ValueError, TypeError):
pass
elif match.lower() == 'state' \
and res.group(2).lower() in ['cancel','close','draft','open','pending']:
act = 'do_%s' % res.group(2).lower()
if act:
getattr(self,act)(cr, uid, ids, context=context)
return super(task,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
return super(task, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
def project_task_reevaluate(self, cr, uid, ids, context=None):
if self.pool.get('res.users').has_group(cr, uid, 'project.group_time_work_estimation_tasks'):

View File

@ -520,8 +520,10 @@ class project_issue(base_stage, osv.osv):
through message_process.
This override updates the document according to the email.
"""
if custom_values is None: custom_values = {}
if context is None: context = {}
if custom_values is None:
custom_values = {}
if context is None:
context = {}
context['state_to'] = 'draft'
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
@ -534,40 +536,10 @@ class project_issue(base_stage, osv.osv):
'partner_id': msg.get('author_id', False),
'user_id': False,
}
if msg.get('priority'):
defaults['priority'] = msg.get('priority')
defaults.update(custom_values)
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
return res_id
def message_update(self, cr, uid, ids, msg, update_vals=None, context=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 isinstance(ids, (str, int, long)):
ids = [ids]
if update_vals is None: update_vals = {}
# Update doc values according to the message
if msg.get('priority'):
update_vals['priority'] = msg.get('priority')
# Parse 'body' to find values to update
maps = {
'cost': 'planned_cost',
'revenue': 'planned_revenue',
'probability': 'probability',
}
for line in msg.get('body', '').split('\n'):
line = line.strip()
res = tools.command_re.match(line)
if res and maps.get(res.group(1).lower(), False):
key = maps.get(res.group(1).lower())
update_vals[key] = res.group(2).lower()
return super(project_issue, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, content_subtype='html', **kwargs):
""" Overrides mail_thread message_post so that we can set the date of last action field when
a new message is posted on the issue.