def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
- if not vals.get('stage_id') and vals.get('project_id'):
+ if not vals.get('stage_id'):
ctx = context.copy()
- ctx['default_project_id'] = vals['project_id']
+ if vals.get('project_id'):
+ ctx['default_project_id'] = vals['project_id']
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
- elif not vals.get('stage_id') and context.get('default_project_id'):
- vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context)
return super(project_issue, self).create(cr, uid, vals, context=context)
def _get_default_project_id(self, cr, uid, context=None):
# Mail gateway
# -------------------------------------------------------
+ def message_get_reply_to(self, cr, uid, ids, context=None):
+ """ Override to get the reply_to of the parent project. """
+ return [issue.project_id.message_get_reply_to()[0] if issue.project_id else False
+ for issue in self.browse(cr, uid, ids, context=context)]
+
def message_new(self, cr, uid, msg, custom_values=None, context=None):
""" Overrides mail_thread message_new that is called by the mailgateway
through message_process.
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'),
+ 'partner_id': msg.get('author_id', False),
'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):