[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:
parent
06c8267768
commit
9537e55894
|
@ -188,7 +188,8 @@ class crm_claim(base_stage, osv.osv):
|
||||||
through message_process.
|
through message_process.
|
||||||
This override updates the document according to the email.
|
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 ''
|
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||||
defaults = {
|
defaults = {
|
||||||
'name': msg.get('subject') or _("No Subject"),
|
'name': msg.get('subject') or _("No Subject"),
|
||||||
|
@ -200,33 +201,7 @@ class crm_claim(base_stage, osv.osv):
|
||||||
if msg.get('priority'):
|
if msg.get('priority'):
|
||||||
defaults['priority'] = msg.get('priority')
|
defaults['priority'] = msg.get('priority')
|
||||||
defaults.update(custom_values)
|
defaults.update(custom_values)
|
||||||
return super(crm_claim,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
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)
|
|
||||||
|
|
||||||
class res_partner(osv.osv):
|
class res_partner(osv.osv):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
|
|
@ -98,7 +98,8 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
|
||||||
through message_process.
|
through message_process.
|
||||||
This override updates the document according to the email.
|
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 ''
|
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||||
defaults = {
|
defaults = {
|
||||||
'name': msg.get('subject') or _("No Subject"),
|
'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),
|
'partner_id': msg.get('author_id', False),
|
||||||
}
|
}
|
||||||
defaults.update(custom_values)
|
defaults.update(custom_values)
|
||||||
return super(crm_helpdesk,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
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)
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -352,7 +352,8 @@ class hr_applicant(base_stage, osv.Model):
|
||||||
through message_process.
|
through message_process.
|
||||||
This override updates the document according to the email.
|
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 ''
|
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||||
defaults = {
|
defaults = {
|
||||||
'name': msg.get('subject') or _("No Subject"),
|
'name': msg.get('subject') or _("No Subject"),
|
||||||
|
@ -365,38 +366,7 @@ class hr_applicant(base_stage, osv.Model):
|
||||||
if msg.get('priority'):
|
if msg.get('priority'):
|
||||||
defaults['priority'] = msg.get('priority')
|
defaults['priority'] = msg.get('priority')
|
||||||
defaults.update(custom_values)
|
defaults.update(custom_values)
|
||||||
return super(hr_applicant,self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
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)
|
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
|
|
|
@ -1206,20 +1206,21 @@ class task(base_stage, osv.osv):
|
||||||
|
|
||||||
def message_new(self, cr, uid, msg, custom_values=None, context=None):
|
def message_new(self, cr, uid, msg, custom_values=None, context=None):
|
||||||
""" Override to updates the document according to the email. """
|
""" Override to updates the document according to the email. """
|
||||||
if custom_values is None: custom_values = {}
|
if custom_values is None:
|
||||||
|
custom_values = {}
|
||||||
defaults = {
|
defaults = {
|
||||||
'name': msg.get('subject'),
|
'name': msg.get('subject'),
|
||||||
'planned_hours': 0.0,
|
'planned_hours': 0.0,
|
||||||
}
|
}
|
||||||
defaults.update(custom_values)
|
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):
|
def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
|
||||||
""" Override to update the task according to the email. """
|
""" Override to update the task according to the email. """
|
||||||
if update_vals is None: update_vals = {}
|
if update_vals is None:
|
||||||
act = False
|
update_vals = {}
|
||||||
maps = {
|
maps = {
|
||||||
'cost':'planned_hours',
|
'cost': 'planned_hours',
|
||||||
}
|
}
|
||||||
for line in msg['body'].split('\n'):
|
for line in msg['body'].split('\n'):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -1232,12 +1233,7 @@ class task(base_stage, osv.osv):
|
||||||
update_vals[field] = float(res.group(2).lower())
|
update_vals[field] = float(res.group(2).lower())
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
elif match.lower() == 'state' \
|
return super(task, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
||||||
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)
|
|
||||||
|
|
||||||
def project_task_reevaluate(self, cr, uid, ids, context=None):
|
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'):
|
if self.pool.get('res.users').has_group(cr, uid, 'project.group_time_work_estimation_tasks'):
|
||||||
|
|
|
@ -520,8 +520,10 @@ class project_issue(base_stage, osv.osv):
|
||||||
through message_process.
|
through message_process.
|
||||||
This override updates the document according to the email.
|
This override updates the document according to the email.
|
||||||
"""
|
"""
|
||||||
if custom_values is None: custom_values = {}
|
if custom_values is None:
|
||||||
if context is None: context = {}
|
custom_values = {}
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
context['state_to'] = 'draft'
|
context['state_to'] = 'draft'
|
||||||
|
|
||||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
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),
|
'partner_id': msg.get('author_id', False),
|
||||||
'user_id': False,
|
'user_id': False,
|
||||||
}
|
}
|
||||||
if msg.get('priority'):
|
|
||||||
defaults['priority'] = msg.get('priority')
|
|
||||||
|
|
||||||
defaults.update(custom_values)
|
defaults.update(custom_values)
|
||||||
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
|
||||||
return res_id
|
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):
|
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
|
""" 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.
|
a new message is posted on the issue.
|
||||||
|
|
Loading…
Reference in New Issue