'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):

    self = self.with_context(default_user_id=False)
    val = msg.get('from').split('<')[0]
    defaults = {'name': (msg.get('subject') or _('No    Subject')), 'partner_name': val, 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'partner_id': msg.get('author_id', False)}
    if msg.get('priority'):
        defaults['priority'] = msg.get('priority')
    if custom_values:
        defaults.update(custom_values)
    return super(Applicant, self).message_new(msg, custom_values=defaults)
