odoo email

 
There are three ways to receive the mail server successfully and handle it accordingly:
1. Create a new record using the server's
Then write a model that inherits the type that is written. At this time, the new_message method can be rewritten to achieve the purpose.
    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.
            This override updates the document according to the email.
        """
        if custom_values is None:
            custom_values = {}
        street = html2plaintext(msg.get('body')) if msg.get('body') else ''
        defaults = {
            'name': msg.get('subject') or _("No Subject"),
            'street': street,
            'email_from': msg.get('from'),
            'email_cc': msg.get('cc'),
            'user_id': False,
            'partner_id': msg.get('author_id', False),
        }
        defaults.update(custom_values)
        return super(ResPartner, self).message_new(cr, uid, msg, custom_values=defaults, context=context)
 
 
2. Use server actions to add aliases
3. Only use aliases
Using an alias allows you to specify a model
Implement the update_message method of this model (usually specify the user, because the user has a portaltemplate, which is used to receive this message)
    
def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
        for user in self.browse(cr, uid, ids, context=context):
            print user.alias_defaults
       
        street = html2plaintext(msg.get('body')) if msg.get('body') else ''
        defaults = {
            'name': msg.get('subject') or _("No Subject"),
            'street': street,
            'email_from': msg.get('from'),
            'email_cc': msg.get('cc'),
            'user_id': False,
            'partner_id': msg.get('author_id', False),
        }
        print defaults
        return True
 
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327081251&siteId=291194637