Skip to Content
Menu
This question has been flagged
3 Replies
5040 Views

I have applied the following python.

# -*- coding: utf-8 -*-

from odoo import _, api, exceptions, fields, models, tools, registry

class MailThread(models.AbstractModel):
_inherit = "mail.thread"

message_reply = fields.Boolean(
'Partner Reply', help="If checked, Partner has replied to message.")

def message_update(self, msg, update_vals=None):
self.message_reply = 'True'
return super(MailThread, self).message_update(msg, update_vals=update_vals)

@api.model
def message_new(self, msg, custom_vals=None):
self.message_reply = 'True'
return super(MailThread, self).message_new(msg, custom_vals=custom_vals)

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
if self.message_reply:
self.update({'message_reply' : False,})
return super(MailThread, self).message_post(**kwargs)


The methods for message_update and message_new, work as expected. However the message_post, throws the following error.

psycopg2.ProgrammingError: operator does not exist: integer = text
LINE 17: WHERE m.id = ANY (ARRAY['mail.message(149,)'...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

I am totally lost.

Avatar
Discard

My first note is this : self.message_reply = 'True'

you should write : self.message_reply = True

Author Best Answer

Thank you, I changed the values from 'True' to True, but unfortunately, I am still getting the error. The method that is failing is the message_post method. But having stated this, I could be wrong and will investigate further. Thank you for your help.

Avatar
Discard
Best Answer

Hi,

You define   message_reply field as Boolean so to when assign value to it you have to use True or False 

So change the below and give it a try:


def message_update(self, msg, update_vals=None):
    self.message_reply = True
    return super(MailThread, self).message_update(msg, update_vals=update_vals)

@api.model
def message_new(self, msg, custom_vals=None):
    self.message_reply =True
    return super(MailThread, self).message_new(msg, custom_vals=custom_vals)
Avatar
Discard
Related Posts Replies Views Activity
2
Jun 24
6256
2
Mar 24
342
2
Jul 23
3946
1
Dec 22
7558
1
Dec 22
2641