details:   https://code.tryton.org/tryton/commit/b1263c34220e
branch:    default
user:      Cédric Krier <[email protected]>
date:      Wed Apr 01 13:06:11 2026 +0200
description:
        Add ModelView to chat message

        It is needed to store the message as result on the inbound email.

        Closes #14729
diffstat:

 trytond/trytond/ir/chat.py                    |  18 +++++++++++++-
 trytond/trytond/ir/chat.xml                   |  35 +++++++++++++++++++++++++++
 trytond/trytond/ir/view/chat_message_form.xml |  18 +++++++++++++
 trytond/trytond/ir/view/chat_message_list.xml |  10 +++++++
 4 files changed, 80 insertions(+), 1 deletions(-)

diffs (121 lines):

diff -r 7ac7c072513b -r b1263c34220e trytond/trytond/ir/chat.py
--- a/trytond/trytond/ir/chat.py        Wed Apr 01 13:05:17 2026 +0200
+++ b/trytond/trytond/ir/chat.py        Wed Apr 01 13:06:11 2026 +0200
@@ -528,13 +528,16 @@
                 ).save()
 
 
-class Message(AuthorMixin, ModelSQL):
+class Message(AuthorMixin, ModelSQL, ModelView):
     "Chat Message"
     __name__ = 'ir.chat.message'
 
     channel = fields.Many2One(
         'ir.chat.channel', "Channel", required=True, ondelete='RESTRICT')
     content = fields.Text("Content", required=True)
+    summary = fields.Function(
+        fields.Char("Summary"), 'on_change_with_summary',
+        searcher='search_summary')
     audience = fields.Selection([
             ('internal', "Internal"),
             ('public', "Public"),
@@ -542,6 +545,19 @@
     reference = fields.Char("Reference", readonly=True)
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.__access__.add('channel')
+
+    @fields.depends('content')
+    def on_change_with_summary(self, name=None):
+        return firstline(self.content or '')
+
+    @classmethod
+    def search_summary(cls, name, clause):
+        return [('content', *clause[1:])]
+
+    @classmethod
     def default_audience(cls):
         return 'public'
 
diff -r 7ac7c072513b -r b1263c34220e trytond/trytond/ir/chat.xml
--- a/trytond/trytond/ir/chat.xml       Wed Apr 01 13:05:17 2026 +0200
+++ b/trytond/trytond/ir/chat.xml       Wed Apr 01 13:06:11 2026 +0200
@@ -70,5 +70,40 @@
             <field name="name">chat_follower_form</field>
         </record>
 
+        <record model="ir.ui.view" id="chat_message_view_list">
+            <field name="model">ir.chat.message</field>
+            <field name="type">tree</field>
+            <field name="name">chat_message_list</field>
+        </record>
+
+        <record model="ir.ui.view" id="chat_message_view_form">
+            <field name="model">ir.chat.message</field>
+            <field name="type">form</field>
+            <field name="name">chat_message_form</field>
+        </record>
+
+        <record model="ir.action.act_window" id="act_chat_message">
+            <field name="name">Messages</field>
+            <field name="res_model">ir.chat.message</field>
+            <field
+                name="domain"
+                eval="[('channel', 'in', Eval('active_ids', []))]"
+                pyson="1"/>
+        </record>
+        <record model="ir.action.act_window.view" id="act_chat_message_view1">
+            <field name="sequence" eval="10"/>
+            <field name="view" ref="chat_message_view_list"/>
+            <field name="act_window" ref="act_chat_message"/>
+        </record>
+        <record model="ir.action.act_window.view" id="act_chat_message_view2">
+            <field name="sequence" eval="20"/>
+            <field name="view" ref="chat_message_view_form"/>
+            <field name="act_window" ref="act_chat_message"/>
+        </record>
+        <record model="ir.action.keyword" id="act_chat_message_keyword1">
+            <field name="keyword">form_relate</field>
+            <field name="model">ir.chat.channel,-1</field>
+            <field name="action" ref="act_chat_message"/>
+        </record>
     </data>
 </tryton>
diff -r 7ac7c072513b -r b1263c34220e 
trytond/trytond/ir/view/chat_message_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/trytond/ir/view/chat_message_form.xml     Wed Apr 01 13:06:11 
2026 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<form col="2">
+    <label name="channel"/>
+    <field name="channel"/>
+
+    <label name="user"/>
+    <field name="user"/>
+
+    <label name="email"/>
+    <field name="email"/>
+
+    <label name="audience"/>
+    <field name="audience"/>
+
+    <field name="content" colspan="2"/>
+</form>
diff -r 7ac7c072513b -r b1263c34220e 
trytond/trytond/ir/view/chat_message_list.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/trytond/ir/view/chat_message_list.xml     Wed Apr 01 13:06:11 
2026 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tree>
+    <field name="channel"/>
+    <field name="author"/>
+    <field name="summary" expand="2"/>
+    <field name="reference" expand="1" optional="1"/>
+    <field name="audience" optional="0"/>
+</tree>

Reply via email to