Search code examples
pythonodoo

odoo 14 message_new in custom module


I create a custom module that should receive mail incoming mail. After configuring the Incoming Mail Servers I tested it with the creating ticket in helpdesk but when I use my module nothing happens not receiving log am don't something wrong

Thank you for the help

from odoo import api, fields, models, tools, _
import logging
_logger = logging.getLogger(__name__)


class TestMailer(models.Model):
    _name = 'test.mailer'
    _inherit = ['mail.alias.mixin','mail.thread', 'mail.activity.mixin']
    _description = 'Sort Email'
    

    name = fields.Char(string='Name')
    email_from = fields.Char(string='email from')
    email_cc = fields.Char(string='email cc')
    mail_body = fields.Text(string='mail body')
    partner_id = fields.Many2one('res.partner', 'Partner',required=True,select=True)

    @api.model
    def message_new(msg_dict, custom_values=None):
    # def message_new(self, msg, custom_values=None):
        _logger.warning('hi i am message_new')

I get this when I fetch now in Incoming Mail Servers.

odoo.addons.mail.models.mail_thread: Routing mail from "name" <[email protected]> to [email protected],"[email protected]" <[email protected]> with Message-Id <DBBPR08MB49043139E291E368A928E963EA0F9@DBBPR08MB4904.eurprd08.prod.outlook.com>: fallback to model:test.mailer, thread_id:None, custom_values:None, uid:2

what is read

Create a new record on Incoming Mails odoo

customize the auto lead creation through incoming emails

solution

@api.model
    def message_new(self, msg, custom_values=None):
        _logger.warning('hi i am message_new')
    return super(TestMailer, self).message_new(msg_dict, custom_values=defaults)



Solution

  • i think you forgot super call in this method...