You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.8 KiB
49 lines
1.8 KiB
# -*- coding: utf-8 -*-
|
|
#############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
|
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
|
|
#
|
|
# You can modify it under the terms of the GNU LESSER
|
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
|
|
# (LGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#############################################################################
|
|
from odoo import models, fields, api
|
|
|
|
|
|
class Message(models.Model):
|
|
_inherit = 'mail.message'
|
|
|
|
is_pinned = fields.Boolean(string='Pinned', default=False, index=True)
|
|
|
|
@api.model
|
|
def message_fetch(self, domain, fields, limit=None, order='id desc'):
|
|
"""Override to always include pinned status"""
|
|
if fields and 'is_pinned' not in fields:
|
|
fields.append('is_pinned')
|
|
return super().message_fetch(domain, fields, limit=limit, order=order)
|
|
|
|
def toggle_pin(self):
|
|
"""Toggle the pinned status of messages."""
|
|
for message in self:
|
|
message.is_pinned = not message.is_pinned
|
|
self.env['bus.bus']._sendone(
|
|
f'{self._name},{message.id}',
|
|
'mail.message/pin_changed',
|
|
{
|
|
'id': message.id,
|
|
'is_pinned': message.is_pinned,
|
|
}
|
|
)
|
|
return True
|
|
|