diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-02-10 12:38:52 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-02-10 13:05:04 +0000 |
| commit | 5018b01dc7e0e5f2c2198367f13ec41b1ed402c7 (patch) | |
| tree | 203d080acdde573908db7eff49030adbb924b4c7 | |
| parent | b7ade94c30cfb78dbb94d01b76be17f7175e1eb2 (diff) | |
[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>
| -rw-r--r-- | addons/hr_holidays/models/mail_channel.py | 4 | ||||
| -rw-r--r-- | addons/mail/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/mail/models/ir_http.py | 1 | ||||
| -rw-r--r-- | addons/mail/models/mail_channel.py | 6 | ||||
| -rw-r--r-- | addons/mail/models/res_users.py | 5 | ||||
| -rw-r--r-- | addons/mail/static/src/js/models/threads/abstract_thread.js | 10 | ||||
| -rw-r--r-- | addons/mail/static/src/js/models/threads/dm_chat.js | 13 | ||||
| -rw-r--r-- | addons/mail/static/src/js/services/mail_status_manager.js | 1 | ||||
| -rw-r--r-- | addons/mail/static/src/js/thread_windows/thread_window.js | 25 | ||||
| -rw-r--r-- | addons/mail/static/src/js/user_menu.js | 22 | ||||
| -rw-r--r-- | addons/mail/static/src/scss/out_of_office.scss | 11 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/out_of_office.xml | 4 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/user_menu.xml | 11 | ||||
| -rw-r--r-- | addons/mail/static/tests/discuss_tests.js | 39 | ||||
| -rw-r--r-- | addons/mail/static/tests/thread_window/basic_thread_window_tests.js | 138 | ||||
| -rw-r--r-- | addons/mail/views/mail_templates.xml | 1 | ||||
| -rw-r--r-- | addons/test_mail/tests/test_mail_channel.py | 13 |
17 files changed, 7 insertions, 298 deletions
diff --git a/addons/hr_holidays/models/mail_channel.py b/addons/hr_holidays/models/mail_channel.py index c5dd68986d7..3e29066bf08 100644 --- a/addons/hr_holidays/models/mail_channel.py +++ b/addons/hr_holidays/models/mail_channel.py @@ -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() diff --git a/addons/mail/__manifest__.py b/addons/mail/__manifest__.py index 0eaa6a216a0..c3dd33c9aa3 100644 --- a/addons/mail/__manifest__.py +++ b/addons/mail/__manifest__.py @@ -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', ], diff --git a/addons/mail/models/ir_http.py b/addons/mail/models/ir_http.py index 7285b3447b0..400b8dee7d8 100644 --- a/addons/mail/models/ir_http.py +++ b/addons/mail/models/ir_http.py @@ -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 diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index ea1174c52ea..043bf10dfe2 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -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): diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index 7be2aa7e52b..d7b414eac7c 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -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 diff --git a/addons/mail/static/src/js/models/threads/abstract_thread.js b/addons/mail/static/src/js/models/threads/abstract_thread.js index 6961ba48175..ed10e761d62 100644 --- a/addons/mail/static/src/js/models/threads/abstract_thread.js +++ b/addons/mail/static/src/js/models/threads/abstract_thread.js @@ -83,14 +83,6 @@ var AbstractThread = Class.extend(Mixins.EventDispatcherMixin, { 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.) * * @returns {string} @@ -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. diff --git a/addons/mail/static/src/js/models/threads/dm_chat.js b/addons/mail/static/src/js/models/threads/dm_chat.js index 6b56cd2c80d..b811b5a5cd5 100644 --- a/addons/mail/static/src/js/models/threads/dm_chat.js +++ b/addons/mail/static/src/js/models/threads/dm_chat.js @@ -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'; @@ -78,15 +76,6 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, { 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 */ getPreview: function () { @@ -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(), diff --git a/addons/mail/static/src/js/services/mail_status_manager.js b/addons/mail/static/src/js/services/mail_status_manager.js index a40299a02d5..184499e8bb4 100644 --- a/addons/mail/static/src/js/services/mail_status_manager.js +++ b/addons/mail/static/src/js/services/mail_status_manager.js @@ -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, }); }); diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js index f7f0c23dd7b..4bd1e6c15ff 100644 --- a/addons/mail/static/src/js/thread_windows/thread_window.js +++ b/addons/mail/static/src/js/thread_windows/thread_window.js @@ -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 @@ -314,15 +298,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 * @param {KeyboardEvent} ev diff --git a/addons/mail/static/src/js/user_menu.js b/addons/mail/static/src/js/user_menu.js deleted file mode 100644 index 77235c1f166..00000000000 --- a/addons/mail/static/src/js/user_menu.js +++ /dev/null @@ -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; - }, -}); - -}); diff --git a/addons/mail/static/src/scss/out_of_office.scss b/addons/mail/static/src/scss/out_of_office.scss index 7ddbdd5d355..bcdb3a182f7 100644 --- a/addons/mail/static/src/scss/out_of_office.scss +++ b/addons/mail/static/src/scss/out_of_office.scss @@ -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; - } } diff --git a/addons/mail/static/src/xml/out_of_office.xml b/addons/mail/static/src/xml/out_of_office.xml index 89723daf5dc..19fb2c341c6 100644 --- a/addons/mail/static/src/xml/out_of_office.xml +++ b/addons/mail/static/src/xml/out_of_office.xml @@ -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> diff --git a/addons/mail/static/src/xml/user_menu.xml b/addons/mail/static/src/xml/user_menu.xml deleted file mode 100644 index 1240d4744fb..00000000000 --- a/addons/mail/static/src/xml/user_menu.xml +++ /dev/null @@ -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> diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index 22c6ae5ad55..7033b8c8b15 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -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(); -}); - }); }); diff --git a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js index 597e197ca9d..87e3c536998 100644 --- a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js +++ b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js @@ -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); diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml index f2f5ee4e905..beddb29cadf 100644 --- a/addons/mail/views/mail_templates.xml +++ b/addons/mail/views/mail_templates.xml @@ -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 --> diff --git a/addons/test_mail/tests/test_mail_channel.py b/addons/test_mail/tests/test_mail_channel.py index e14fd727eae..3fb07f010ce 100644 --- a/addons/test_mail/tests/test_mail_channel.py +++ b/addons/test_mail/tests/test_mail_channel.py @@ -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): |
