İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
42255 Görünümler

my work is need to send internal log message to email ,i inherited mail.message model in create method but i got recursion error with below code:

class MessageViaEmail(models.Model):
    _inherit = 'mail.message'

    @api.model
    def create(self, values):
        message = super(MessageViaEmail, self).create(values)
        mail_obj = self.env['mail.mail']

        mail_obj.create({
            'email_to': 'xxxxxxxxxxxxxxxxxx.k@247c.in',
            'subject': "sample subject",
            'body_html':
                '''<span  style="font-size:14px"><br/>
                <br/>%s</span>
                <br/>%s</span>
                <br/><br/>''' % ("body", "footer"),
        }).send(self)

               
        return message

but i got recursion error:

  File "/home/iswasu-8/odoo-10.0-20170824/odoo/addons/mail/models/mail_message.py", line 752, in read
    return super(Message, self).read(fields=fields, load=load)
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/models.py", line 2991, in read
    self.check_access_rights('read')
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/models.py", line 3285, in check_access_rights
    return self.env['ir.model.access'].check(self._name, operation, raise_exception)
  File "<decorator-gen-4>", line 2, in check
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/tools/cache.py", line 82, in lookup
    r = d[key]
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/tools/lru.py", line 44, in __getitem__
    self[a[0]] = a[1]
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/home/iswasu-8/odoo-10.0-20170824/odoo/tools/lru.py", line 50, in __setitem__
    del self[obj]
RuntimeError: maximum recursion depth exceeded while calling a Python object


can any one please give me solution.



Avatar
Vazgeç
En İyi Yanıt

Hi,

Inside the create function of the object mail.messageyou are calling the create method of the model mail.mail . As the model mail.mail inherits the model mail.message,  which will call the create method of the mail.message.  And this will go on.

That's why you are getting the error.

Thanks

Avatar
Vazgeç
En İyi Yanıt

KLN,

You are calling the create method inside the create method, that's why it is showing the recursion error.

Thank You.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Tem 23
26423
2
Haz 22
5457
2
Eyl 21
4373
1
Kas 20
7647
2
Mar 19
5779