[FIX] mail_thread subclasses: message_new must not override the explicitly provided...
authorOlivier Dony <odo@openerp.com>
Thu, 10 Jan 2013 17:27:23 +0000 (18:27 +0100)
committerOlivier Dony <odo@openerp.com>
Thu, 10 Jan 2013 17:27:23 +0000 (18:27 +0100)
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

addons/crm/crm_lead.py
addons/crm_claim/crm_claim.py
addons/crm_helpdesk/crm_helpdesk.py
addons/hr_recruitment/hr_recruitment.py
addons/project/project.py
addons/project_issue/project_issue.py

index 2fb81a0..ab6770a 100644 (file)
@@ -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
index 5aaa658..a724579 100644 (file)
@@ -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
index a707787..5ed1c04 100644 (file)
@@ -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
index 33e32d9..44d8912 100644 (file)
@@ -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
index 3c7c180..95f7771 100644 (file)
@@ -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. """
index 5a757fd..7b7b6f8 100644 (file)
@@ -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):