The commit is to refactor the discuss sidebar - threads are now organized in categories based on the thread type e.g. chat, channel - categories can be folded or unfolded by clicking the category title - for active thread, even if the category is folded, it remains under the category title - for channel category, a new cog button is added to view all channels - the active indicator bar is removed. The active item now is highlighted with a different background color - thread avatar is used for livechat, chat and channel - for livechat and chat, threads are now sorted by last activity time (pin or message exchange) closes odoo/odoo#70986 Task-id: 2440073 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ResUsersSettings(models.Model):
|
|
_name = 'res.users.settings'
|
|
_description = 'User Settings'
|
|
|
|
user_id = fields.Many2one('res.users', string="User", required=True, readonly=True, ondelete='cascade')
|
|
is_discuss_sidebar_category_channel_open = fields.Boolean(string="Is discuss sidebar category channel open?", default=True)
|
|
is_discuss_sidebar_category_chat_open = fields.Boolean(string="Is discuss sidebar category chat open?", default=True)
|
|
|
|
_sql_constraints = [
|
|
('unique_user_id', 'UNIQUE(user_id)', 'One user should only have one mail user settings.')
|
|
]
|
|
|
|
@api.model
|
|
def _find_or_create_for_user(self, user):
|
|
settings = user.res_users_settings_ids
|
|
if not settings:
|
|
settings = self.create({'user_id': user.id})
|
|
return settings
|
|
|
|
def _res_users_settings_format(self):
|
|
self.ensure_one()
|
|
return self._read_format(fnames=[name for name, field in self._fields.items() if name == 'id' or not field.automatic])[0]
|
|
|
|
def set_res_users_settings(self, new_settings):
|
|
self.ensure_one()
|
|
changed_settings = {}
|
|
for setting in new_settings.keys():
|
|
if setting in self._fields and new_settings[setting] != self[setting]:
|
|
changed_settings[setting] = new_settings[setting]
|
|
self.write(changed_settings)
|
|
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.user_id.partner_id.id), {
|
|
'type': 'res.users_settings_changed',
|
|
'payload': changed_settings,
|
|
})
|