'Overrides mail_thread message_new that is called by the mailgateway
through message_process.
This override updates the document according to the email.'

@api.model
def message_new(self, msg, custom_values=None):

    create_context = dict((self.env.context or {}))
    create_context['default_user_id'] = False
    defaults = {'name': (msg.get('subject') or _('No    Subject')), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'partner_id': msg.get('author_id', False)}
    if custom_values:
        defaults.update(custom_values)
    res_id = super(ProjectIssue, self.with_context(create_context)).message_new(msg, custom_values=defaults)
    issue = self.browse(res_id)
    email_list = issue.email_split(msg)
    partner_ids = filter(None, issue._find_partner_from_emails(email_list))
    issue.message_subscribe(partner_ids)
    return res_id
