When on leave, the im_status can be either leave_online or leave_offline. This will allow to display a specific icon and a default message when the user is not at the office. The leave can have an out of office message. This message will be displayed in the chat window instead of the user ooo message, and the end date of the leave will be displayed too. Technical details. Right now the im_status access leaves directly to know if a user is on leave or not. An index has been added to optimise this request (thanks to rco). A solution to optimise this would be to compute part of the information in a cron. Task: 1856205
23 lines
697 B
Python
23 lines
697 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
def _compute_im_status(self):
|
|
super(ResPartner, self)._compute_im_status()
|
|
absent_now = self._get_on_leave_ids()
|
|
for partner in self:
|
|
if partner.id in absent_now:
|
|
if partner.im_status == 'online':
|
|
partner.im_status = 'leave_online'
|
|
else:
|
|
partner.im_status = 'leave_offline'
|
|
|
|
@api.model
|
|
def _get_on_leave_ids(self):
|
|
return self.env['res.users']._get_on_leave_ids(partner=True)
|