[FIX] mail_thread subclasses: message_new must not override the explicitly provided `custom_values`
This was the case before, but was broken involuntarily during the big mail refactoring for v7. The default values provided by custom message_new methods should only be used as defaults. bzr revid: odo@openerp.com-20130110172723-ym7mcmdllcucj0j3
This commit is contained in:
@@ -974,16 +974,17 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||
if custom_values is None: custom_values = {}
|
||||
|
||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'description': desc,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
})
|
||||
}
|
||||
if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES):
|
||||
custom_values['priority'] = msg.get('priority')
|
||||
return super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
defaults['priority'] = msg.get('priority')
|
||||
defaults.update(custom_values)
|
||||
return super(crm_lead, 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
|
||||
|
||||
@@ -190,15 +190,16 @@ class crm_claim(base_stage, osv.osv):
|
||||
"""
|
||||
if custom_values is None: custom_values = {}
|
||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'description': desc,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
})
|
||||
}
|
||||
if msg.get('priority'):
|
||||
custom_values['priority'] = msg.get('priority')
|
||||
return super(crm_claim,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
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
|
||||
|
||||
@@ -100,14 +100,15 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
|
||||
"""
|
||||
if custom_values is None: custom_values = {}
|
||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'description': desc,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
})
|
||||
return super(crm_helpdesk,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
}
|
||||
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
|
||||
|
||||
@@ -347,16 +347,17 @@ class hr_applicant(base_stage, osv.Model):
|
||||
"""
|
||||
if custom_values is None: custom_values = {}
|
||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'description': desc,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
})
|
||||
}
|
||||
if msg.get('priority'):
|
||||
custom_values['priority'] = msg.get('priority')
|
||||
return super(hr_applicant,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
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
|
||||
|
||||
@@ -1174,11 +1174,12 @@ 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 = {}
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject'),
|
||||
'planned_hours': 0.0,
|
||||
})
|
||||
return super(task,self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
}
|
||||
defaults.update(custom_values)
|
||||
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. """
|
||||
|
||||
@@ -497,17 +497,18 @@ class project_issue(base_stage, osv.osv):
|
||||
|
||||
desc = html2plaintext(msg.get('body')) if msg.get('body') else ''
|
||||
|
||||
custom_values.update({
|
||||
defaults = {
|
||||
'name': msg.get('subject') or _("No Subject"),
|
||||
'description': desc,
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
})
|
||||
}
|
||||
if msg.get('priority'):
|
||||
custom_values['priority'] = msg.get('priority')
|
||||
defaults['priority'] = msg.get('priority')
|
||||
|
||||
res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user