Discuss Messages
This commit is contained in:
parent
50daabba44
commit
55178e4b15
|
|
@ -1,2 +1,3 @@
|
||||||
from . import hr_employee
|
from . import hr_employee
|
||||||
from . import hr_leave
|
from . import hr_leave
|
||||||
|
from . import discuss
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
from logging import exception
|
||||||
|
|
||||||
|
from odoo import api, models, _, fields
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tools.misc import format_date
|
||||||
|
from datetime import datetime
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
|
class DiscussChannel(models.Model):
|
||||||
|
_inherit = "discuss.channel"
|
||||||
|
|
||||||
|
|
||||||
|
def send_message_from_flutter_odoo(self,leave_request_data,message_type='notification'):
|
||||||
|
for rec in self:
|
||||||
|
attachments = leave_request_data.pop('attachments', [])
|
||||||
|
files = []
|
||||||
|
leave_request_data['body'] = Markup(leave_request_data['body'])
|
||||||
|
# rec.message_post(message_type,leave_request_data)
|
||||||
|
|
||||||
|
if attachments:
|
||||||
|
for att in attachments:
|
||||||
|
file = self.env['ir.attachment'].create({
|
||||||
|
'name': att['name'],
|
||||||
|
'type': 'binary',
|
||||||
|
'datas': att['datas'], # base64 string
|
||||||
|
'res_model': 'discuss.channel',
|
||||||
|
'res_id': rec.id,
|
||||||
|
})
|
||||||
|
files.append(file.id)
|
||||||
|
rec.message_post(
|
||||||
|
body=leave_request_data['body'],
|
||||||
|
message_type="comment",
|
||||||
|
subtype_xmlid="mail.mt_comment",
|
||||||
|
attachment_ids=files # ✅ correct way to pass existing attachments
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue