[IMP] mail, test_mail, hr_holidays: remove obsolete out of office
The customizable "out of office" text was removed from the editable views as part of task-2053585, but some places in the code were still using it, even though it was never set anymore. This commit removes the obsolete code. Part of task-2171864 closes odoo/odoo#44968 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Channel(models.Model):
|
||||
@@ -9,7 +9,7 @@ class Channel(models.Model):
|
||||
|
||||
def partner_info(self, all_partners, direct_partners):
|
||||
partner_infos = super(Channel, self).partner_info(all_partners, direct_partners)
|
||||
# only search for leave out_of_office_message if im_status is on leave
|
||||
# only search for leave out_of_office_date_end if im_status is on leave
|
||||
partners_on_leave = [partner_id for partner_id in direct_partners.ids if 'leave' in partner_infos[partner_id]['im_status']]
|
||||
if partners_on_leave:
|
||||
now = fields.Datetime.now()
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
'static/src/xml/thread.xml',
|
||||
'static/src/xml/abstract_thread_window.xml',
|
||||
'static/src/xml/thread_window.xml',
|
||||
'static/src/xml/user_menu.xml',
|
||||
'static/src/xml/web_kanban_activity.xml',
|
||||
'static/src/xml/text_emojis.xml',
|
||||
],
|
||||
|
||||
@@ -12,6 +12,5 @@ class IrHttp(models.AbstractModel):
|
||||
user = request.env.user
|
||||
result = super(IrHttp, self).session_info()
|
||||
if self.env.user.has_group('base.group_user'):
|
||||
result['out_of_office_message'] = user.out_of_office_message
|
||||
result['notification_type'] = user.notification_type
|
||||
return result
|
||||
|
||||
@@ -504,18 +504,16 @@ class Channel(models.Model):
|
||||
Return the information needed by channel to display channel members
|
||||
:param all_partners: list of res.parner():
|
||||
:param direct_partners: list of res.parner():
|
||||
:returns: a list of {'id', 'name', 'email'} for each partner and adds {im_status, out_of_office_message} for direct_partners.
|
||||
:returns: a list of {'id', 'name', 'email'} for each partner and adds {im_status} for direct_partners.
|
||||
:rtype : list(dict)
|
||||
"""
|
||||
partner_infos = {partner['id']: partner for partner in all_partners.sudo().read(['id', 'name', 'email'])}
|
||||
# add im _status and out_of_office_message for direct_partners
|
||||
# add im _status for direct_partners
|
||||
direct_partners_im_status = {partner['id']: partner for partner in direct_partners.sudo().read(['im_status'])}
|
||||
|
||||
for i in direct_partners_im_status.keys():
|
||||
partner_infos[i].update(direct_partners_im_status[i])
|
||||
|
||||
for user in self.env['res.users'].search([('partner_id', 'in', direct_partners.ids), ('out_of_office_message', '!=', False)]):
|
||||
partner_infos[user.partner_id.id]['out_of_office_message'] = user.out_of_office_message
|
||||
return partner_infos
|
||||
|
||||
def channel_info(self, extra_info=False):
|
||||
|
||||
@@ -38,7 +38,6 @@ class Users(models.Model):
|
||||
moderation_channel_ids = fields.Many2many(
|
||||
'mail.channel', 'mail_channel_moderator_rel',
|
||||
string='Moderated channels')
|
||||
out_of_office_message = fields.Char(string='Chat Status')
|
||||
|
||||
@api.depends('moderation_channel_ids.moderation', 'moderation_channel_ids.moderator_ids')
|
||||
def _compute_is_moderator(self):
|
||||
@@ -73,10 +72,10 @@ GROUP BY channel_moderator.res_users_id""", [tuple(self.ids)])
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
|
||||
type(self).SELF_WRITEABLE_FIELDS.extend(['notification_type', 'out_of_office_message'])
|
||||
type(self).SELF_WRITEABLE_FIELDS.extend(['notification_type'])
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
|
||||
type(self).SELF_READABLE_FIELDS.extend(['notification_type', 'out_of_office_message'])
|
||||
type(self).SELF_READABLE_FIELDS.extend(['notification_type'])
|
||||
return init_res
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -82,14 +82,6 @@ var AbstractThread = Class.extend(Mixins.EventDispatcherMixin, {
|
||||
getOutOfOfficeInfo: function () {
|
||||
return undefined;
|
||||
},
|
||||
/**
|
||||
* By default, threads do not have out-of-office feature
|
||||
*
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
getOutOfOfficeMessage: function () {
|
||||
return undefined;
|
||||
},
|
||||
/**
|
||||
* Get the status of the thread (e.g. 'online', 'offline', etc.)
|
||||
*
|
||||
@@ -122,7 +114,7 @@ var AbstractThread = Class.extend(Mixins.EventDispatcherMixin, {
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasOutOfOffice() {
|
||||
return !!(this.getOutOfOfficeMessage() || this.getOutOfOfficeInfo());
|
||||
return !!this.getOutOfOfficeInfo();
|
||||
},
|
||||
/**
|
||||
* States whether this thread is compatible with the 'seen' feature.
|
||||
|
||||
@@ -23,7 +23,6 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
|
||||
* @param {integer} params.data.direct_partner[0].id
|
||||
* @param {string} params.data.direct_partner[0].im_status
|
||||
* @param {string} params.data.direct_partner[0].name
|
||||
* @param {string} [params.data.direct_partner[0].out_of_office_message]
|
||||
* @param {string} [params.data.direct_partner[0].out_of_office_date_end]
|
||||
*/
|
||||
init: function (params) {
|
||||
@@ -34,7 +33,6 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
|
||||
|
||||
this._directPartnerID = data.direct_partner[0].id;
|
||||
this._name = data.custom_channel_name || data.direct_partner[0].name;
|
||||
this._outOfOfficeMessage = data.direct_partner[0].out_of_office_message;
|
||||
this._outOfOfficeDateEnd = data.direct_partner[0].out_of_office_date_end;
|
||||
this._type = 'dm_chat';
|
||||
|
||||
@@ -77,15 +75,6 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
|
||||
var formattedDate = date.toLocaleDateString(window.navigator.language, options);
|
||||
return _.str.sprintf(_t("Out of office until %s"), formattedDate);
|
||||
},
|
||||
/**
|
||||
* Get the out of office message of the thread
|
||||
*
|
||||
* @override {mail.model.AbstractThread}
|
||||
* @returns {string}
|
||||
*/
|
||||
getOutOfOfficeMessage: function () {
|
||||
return this._outOfOfficeMessage;
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
@@ -104,11 +93,9 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
* @param {string} data.outOfOfficeMessage
|
||||
* @param {string} data.outOfOfficeDateEnd
|
||||
*/
|
||||
updateOutOfOfficeInfo: function (data) {
|
||||
this._outOfOfficeMessage = data.outOfOfficeMessage;
|
||||
this._outOfOfficeDateEnd = data.outOfOfficeDateEnd;
|
||||
this.call('mail_service', 'getMailBus').trigger('updated_out_of_office', {
|
||||
threadID: this.getID(),
|
||||
|
||||
@@ -87,7 +87,6 @@ MailManager.include({
|
||||
return;
|
||||
}
|
||||
dmChat.updateOutOfOfficeInfo({
|
||||
outOfOfficeMessage: channelInfo.direct_partner[0].out_of_office_message,
|
||||
outOfOfficeDateEnd: channelInfo.direct_partner[0].out_of_office_date_end,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ var ThreadWindow = AbstractThreadWindow.extend({
|
||||
'click .o_mail_thread': '_onThreadWindowFocus',
|
||||
'click .o_thread_composer': '_onThreadWindowFocus',
|
||||
'click .o_thread_window_expand': '_onClickExpand',
|
||||
'click .o_out_of_office_read_more_less_button': '_onClickOutOfOfficeReadMoreLess',
|
||||
}),
|
||||
/**
|
||||
* Version of thread window that supports {mail.model.Thread}
|
||||
@@ -92,8 +91,6 @@ var ThreadWindow = AbstractThreadWindow.extend({
|
||||
self.$input = self.$('.o_composer_text_field');
|
||||
});
|
||||
}
|
||||
this._updateOutOfOfficeReadMoreLessButton();
|
||||
|
||||
return Promise.all([superDef, composerDef]);
|
||||
},
|
||||
|
||||
@@ -262,19 +259,6 @@ var ThreadWindow = AbstractThreadWindow.extend({
|
||||
})
|
||||
.focus();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_updateOutOfOfficeReadMoreLessButton: function () {
|
||||
var $readMore = this.$('.o_out_of_office_text');
|
||||
var isOverflowing = $readMore.prop('scrollWidth') > $readMore.width();
|
||||
var isOverflowShown = !$readMore.hasClass('o_text_wrap');
|
||||
if (isOverflowing || isOverflowShown) {
|
||||
var $button = this.$('.o_out_of_office_read_more_less_button');
|
||||
$button.show();
|
||||
$button.text(isOverflowing ? _t('Read more') : _t('Read less'));
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
@@ -313,15 +297,6 @@ var ThreadWindow = AbstractThreadWindow.extend({
|
||||
});
|
||||
}
|
||||
}, 1000, true),
|
||||
/**
|
||||
* @private
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onClickOutOfOfficeReadMoreLess: function (ev) {
|
||||
ev.preventDefault();
|
||||
this.$('.o_out_of_office_text').toggleClass('o_text_wrap');
|
||||
this._updateOutOfOfficeReadMoreLessButton();
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
* @private
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
odoo.define('mail.UserMenu', function (require) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This file includes the UserMenu widget defined in Community to add or
|
||||
* override actions only available in Enterprise.
|
||||
*/
|
||||
|
||||
var UserMenu = require('web.UserMenu');
|
||||
|
||||
UserMenu.include({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
var session = this.getSession();
|
||||
this.outOfOfficeMessage = session.out_of_office_message;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@@ -5,15 +5,4 @@
|
||||
.o_out_of_office_info {
|
||||
font-weight: bold;
|
||||
}
|
||||
.o_out_of_office_text {
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.o_text_wrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.o_out_of_office_read_more_less_button {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,5 @@
|
||||
-->
|
||||
<div class="o_out_of_office" t-name="mail.thread.OutOfOffice">
|
||||
<div class="o_out_of_office_info" t-if="thread.getOutOfOfficeInfo()" t-esc="thread.getOutOfOfficeInfo()"/>
|
||||
<div class="o_out_of_office_text o_text_wrap" t-if="thread.getOutOfOfficeMessage()">
|
||||
<t t-esc="thread.getOutOfOfficeMessage()"/>
|
||||
<a href="#" class="o_out_of_office_read_more_less_button">Read more</a>
|
||||
</div>
|
||||
</div>
|
||||
</templates>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-extend="UserMenu">
|
||||
<t t-jquery=".oe_topbar_name" t-operation="before">
|
||||
<t t-if="widget.outOfOfficeMessage">
|
||||
<i class="o_mail_user_status o_user_idle fa fa-minus-circle" title="You have set a chat message."/>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -1994,44 +1994,5 @@ QUnit.test('save filter discuss', async function (assert) {
|
||||
discuss.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('out-of-office info on discuss', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
this.data.initMessaging = {
|
||||
channel_slots: {
|
||||
channel_direct_message: [{
|
||||
id: 1,
|
||||
channel_type: "chat",
|
||||
direct_partner: [{
|
||||
id: 2,
|
||||
name: "Someone",
|
||||
im_status: "",
|
||||
out_of_office_message: "I'm busy doing nothing",
|
||||
out_of_office_date_end: false
|
||||
}],
|
||||
name: "DM",
|
||||
}],
|
||||
},
|
||||
};
|
||||
const discuss = await createDiscuss({
|
||||
context: {},
|
||||
params: {},
|
||||
data: this.data,
|
||||
services: this.services,
|
||||
});
|
||||
|
||||
const $dmChat = discuss.$('.o_mail_discuss_item[data-thread-id=1]');
|
||||
await testUtils.dom.click($dmChat);
|
||||
assert.containsOnce(discuss, '.o_out_of_office',
|
||||
'should contain out of office section on discuss');
|
||||
assert.containsOnce(discuss, '.o_out_of_office_text',
|
||||
'should contain out of office text on discuss');
|
||||
assert.ok(
|
||||
discuss.$('.o_out_of_office_text').text().trim().includes("I'm busy doing nothing"),
|
||||
'should have content of provided out of office text');
|
||||
|
||||
discuss.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -587,37 +587,6 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
|
||||
parent.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('out-of-office status in thread window', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.data.initMessaging = {
|
||||
channel_slots: {
|
||||
channel_channel: [{
|
||||
id: 1,
|
||||
name: "DM",
|
||||
channel_type: "chat",
|
||||
message_unread_counter: 0,
|
||||
direct_partner: [{ id: 666, name: 'DemoUser1', im_status: 'online', out_of_office_message: 'Please don\'t disturb'}],
|
||||
}],
|
||||
},
|
||||
};
|
||||
var parent = this.createParent({
|
||||
data: this.data,
|
||||
services: this.services,
|
||||
});
|
||||
await testUtils.nextTick();
|
||||
|
||||
// detach channel 1, so that it opens corresponding thread window.
|
||||
var channel = parent.call('mail_service', 'getChannel', 1);
|
||||
await testUtils.nextTick();
|
||||
channel.detach();
|
||||
await testUtils.nextTick();
|
||||
|
||||
var $threadWindow = $('.o_thread_window');
|
||||
assert.containsOnce($threadWindow, '.o_out_of_office_text');
|
||||
|
||||
parent.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('no out-of-office status in thread window', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.data.initMessaging = {
|
||||
@@ -649,113 +618,6 @@ QUnit.test('no out-of-office status in thread window', async function (assert) {
|
||||
parent.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('auto-update out-of-office info on im_status change', async function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
var imStatusDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()];
|
||||
var channelInfoDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()];
|
||||
var timeoutMock = mailTestUtils.patchMailTimeouts();
|
||||
var step = 0;
|
||||
|
||||
this.data.initMessaging = {
|
||||
channel_slots: {
|
||||
channel_channel: [{
|
||||
id: 1,
|
||||
name: "DM",
|
||||
channel_type: "chat",
|
||||
message_unread_counter: 0,
|
||||
direct_partner: [{
|
||||
id: 666,
|
||||
name: 'DemoUser1',
|
||||
im_status: 'online',
|
||||
}],
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
var parent = this.createParent({
|
||||
data: this.data,
|
||||
services: this.services,
|
||||
mockRPC: function (route, args) {
|
||||
if (route === '/longpolling/im_status') {
|
||||
step++;
|
||||
if (step === 1) {
|
||||
imStatusDefs[0].resolve();
|
||||
return Promise.resolve([
|
||||
{
|
||||
id: 666,
|
||||
im_status: 'leave',
|
||||
},
|
||||
]);
|
||||
} else if (step === 2) {
|
||||
imStatusDefs[1].resolve();
|
||||
return Promise.resolve([
|
||||
{
|
||||
id: 666,
|
||||
im_status: 'online',
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (args.method === 'channel_info') {
|
||||
if (step === 1) {
|
||||
channelInfoDefs[0].resolve();
|
||||
return Promise.resolve([{
|
||||
id: 1,
|
||||
direct_partner: [{
|
||||
out_of_office_message: "Leave me alone",
|
||||
out_of_office_date_end: false,
|
||||
}],
|
||||
}]);
|
||||
}
|
||||
else if (step === 2) {
|
||||
channelInfoDefs[1].resolve();
|
||||
return Promise.resolve([{
|
||||
id: 1,
|
||||
direct_partner: [{
|
||||
out_of_office_message: false,
|
||||
out_of_office_date_end: false,
|
||||
}],
|
||||
}]);
|
||||
}
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
await testUtils.nextTick();
|
||||
|
||||
// detach channel 1, so that it opens corresponding thread window.
|
||||
parent.call('mail_service', 'getChannel', 1).detach();
|
||||
await testUtils.nextTick();
|
||||
|
||||
assert.containsNone($, '.o_out_of_office',
|
||||
"should contain no out of office section on chat window initially");
|
||||
|
||||
timeoutMock.addTime(51*1000); // wait for next im status fetch
|
||||
|
||||
await Promise.all([imStatusDefs[0], channelInfoDefs[0]]);
|
||||
await testUtils.nextTick();
|
||||
assert.containsOnce($, '.o_out_of_office',
|
||||
"should contain out of office section on chat window");
|
||||
assert.containsOnce($, '.o_out_of_office > .o_out_of_office_text',
|
||||
"should contain out of office text on chat window");
|
||||
assert.ok(
|
||||
$('.o_out_of_office > .o_out_of_office_text')
|
||||
.text()
|
||||
.replace(/\s/g, "")
|
||||
.indexOf("Leavemealone") !== -1,
|
||||
"should contain out of office text on chat window");
|
||||
timeoutMock.addTime(51*1000); // wait for next im status fetch
|
||||
|
||||
await Promise.all([imStatusDefs[1], channelInfoDefs[1]]);
|
||||
await testUtils.nextTick();
|
||||
assert.containsNone($, '.o_out_of_office',
|
||||
"should no longer contain out of office section on chat window");
|
||||
|
||||
timeoutMock.runPendingTimeouts();
|
||||
parent.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('receive 2 new DM messages in quick succession (no chat window initially)', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
<script type="text/javascript" src="/mail/static/src/js/systray/systray_activity_menu.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/systray/systray_messaging_menu.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/tours/mail.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/user_menu.js"></script>
|
||||
<!-- tools -->
|
||||
<script type="text/javascript" src="/mail/static/src/js/tools/debug_manager.js"></script>
|
||||
<!-- filter menu -->
|
||||
|
||||
@@ -195,19 +195,6 @@ class TestChannelFeatures(TestMailCommon):
|
||||
self.test_channel.message_post(body="Test", message_type='comment', subtype_xmlid='mail.mt_comment')
|
||||
self.assertSentEmail(self.test_channel.env.user.partner_id, [self.test_partner])
|
||||
|
||||
@mute_logger('odoo.addons.mail.models.mail_mail')
|
||||
def test_channel_out_of_office(self):
|
||||
self.user_employee.out_of_office_message = 'Out'
|
||||
test_chat = self.env['mail.channel'].with_context(self._test_context).create({
|
||||
'channel_partner_ids': [(4, self.user_employee.partner_id.id), (4, self.user_admin.partner_id.id)],
|
||||
'public': 'private',
|
||||
'channel_type': 'chat',
|
||||
'email_send': False,
|
||||
'name': 'test'
|
||||
})
|
||||
infos = test_chat.with_user(self.user_admin).channel_info()
|
||||
self.assertEqual(infos[0]['direct_partner'][0]['out_of_office_message'], 'Out')
|
||||
|
||||
|
||||
@tagged('moderation')
|
||||
class TestChannelModeration(TestMailCommon):
|
||||
|
||||
Reference in New Issue
Block a user