This commit is contained in:
2026-11-08 20:08:53 +08:00
parent 7526a5fe4d
commit 9b924747c5
2692 changed files with 394867 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class MailMessage(models.Model):
_inherit = "mail.message"
def _ai_read(self, fnames=None, files_parts=None, files_checksums=None):
"""When messages are inserted in a prompt, one send the subject, body, author_id and date
of mail messages to the LLM.
"""
if fnames:
return super()._ai_read(fnames, files_parts, files_checksums)
# when a message field is inserted in an AI prompt, the subject, body, date and author
# of the mail messages are sent to the LLM
msg_subtype = self.env.ref('mail.mt_comment')
msg_types = ('comment', 'email', 'email_outgoing')
return super(MailMessage, self.filtered(
lambda m: m.message_type in msg_types and m.subtype_id == msg_subtype
))._ai_read(['subject', 'body', 'author_id', 'date'], files_parts, files_checksums)