[FIX] website_livechat: missing decorator on message_post
Incorrect override of message_post. Without this decorator, message_post returns a string `mail.message(ID,)` via RPC. Discuss needs the message ID to scroll chat window closes odoo/odoo#57123 X-original-commit: 3939d3aa3b60e0f606a9f7defd695417f7b3f383 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
committed by
Alexandre Kühn
parent
8d96bfd080
commit
467208f6e4
@@ -10,6 +10,7 @@ from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
|
||||
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tools import mute_logger, formataddr
|
||||
from odoo.api import call_kw
|
||||
|
||||
|
||||
class TestMessagePost(TestMailCommon, TestRecipients):
|
||||
@@ -294,3 +295,13 @@ class TestMessagePost(TestMailCommon, TestRecipients):
|
||||
subject='About %s' % test_record.name,
|
||||
body_content=test_record.name,
|
||||
attachments=[('first.txt', b'My first attachment', 'text/plain'), ('second.txt', b'My second attachment', 'text/plain')])
|
||||
|
||||
# This method should be run inside a post_install class to ensure that all
|
||||
# message_post overrides are tested.
|
||||
def test_message_post_return(self):
|
||||
test_channel = self.env['mail.channel'].create({
|
||||
'name': 'Test',
|
||||
})
|
||||
# Use call_kw as shortcut to simulate a RPC call.
|
||||
messageId = call_kw(self.env['mail.channel'], 'message_post', [test_channel.id], {'body': 'test'})
|
||||
self.assertTrue(isinstance(messageId, int))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class MailChannel(models.Model):
|
||||
@@ -62,6 +62,7 @@ class MailChannel(models.Model):
|
||||
|
||||
return message
|
||||
|
||||
@api.returns('mail.message', lambda value: value.id)
|
||||
def message_post(self, **kwargs):
|
||||
"""Override to mark the visitor as still connected.
|
||||
If the message sent is not from the operator (so if it's the visitor or
|
||||
|
||||
Reference in New Issue
Block a user