[FIX] mail: dicuss can save favorite filters
In discuss, make a search with some stuff, and try to save that filter as favorite Before this commit, there was a crash, because the Discuss action did not implement what the controllers do to save favorites. After this commit, it is possible to save a filter as favorite OPW 2087258 closes odoo/odoo#39519 X-original-commit: 5514a414324675bf5c2cc0360e429a7d2548b16f Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
committed by
fw-bot
parent
72fa7d7015
commit
0562940f2c
@@ -240,12 +240,12 @@ var ModeratorRejectMessageDialog = Dialog.extend({
|
||||
|
||||
var Discuss = AbstractAction.extend({
|
||||
contentTemplate: 'mail.discuss',
|
||||
custom_events: {
|
||||
custom_events: _.extend({}, AbstractAction.prototype.custom_events, {
|
||||
discard_extended_composer: '_onDiscardExtendedComposer',
|
||||
message_moderation: '_onMessageModeration',
|
||||
search: '_onSearch',
|
||||
update_moderation_buttons: '_onUpdateModerationButtons',
|
||||
},
|
||||
}),
|
||||
events: {
|
||||
'click .o_mail_sidebar_title .o_add': '_onAddThread',
|
||||
'blur .o_mail_add_thread input': '_onAddThreadBlur',
|
||||
|
||||
@@ -1966,5 +1966,63 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
|
||||
discuss.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('save filter discuss', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var messageFetchCount = 0;
|
||||
const discuss = await createDiscuss({
|
||||
context: {},
|
||||
params: {},
|
||||
data: this.data,
|
||||
services: this.services,
|
||||
archs: {
|
||||
'mail.message,false,search': '<search>' +
|
||||
'<field name="body" string="Content" filter_domain="[\'|\', (\'subject\', \'ilike\', self), (\'body\', \'ilike\', self)]"/>' +
|
||||
'</search>',
|
||||
},
|
||||
session: {
|
||||
partner_id: 3
|
||||
},
|
||||
mockRPC: async function (route, args) {
|
||||
if (args.method === 'message_fetch' && messageFetchCount === 1) {
|
||||
assert.deepEqual(args.args[0], [
|
||||
["needaction", "=", true],
|
||||
"|",
|
||||
["subject", "ilike", "she was born in a hurricane"],
|
||||
["body", "ilike", "she was born in a hurricane"],
|
||||
], 'The fetch domain is correct');
|
||||
}
|
||||
return this._super.apply(this,arguments);
|
||||
},
|
||||
intercepts: {
|
||||
create_filter: function (ev) {
|
||||
assert.deepEqual(
|
||||
JSON.parse(ev.data.filter.domain), [
|
||||
"|",
|
||||
["subject", "ilike", "she was born in a hurricane"],
|
||||
["body", "ilike", "she was born in a hurricane"]
|
||||
], 'The filter should have been saved with the right domain');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
assert.containsOnce(discuss, '.o_searchview_input_container', 'search view input present');
|
||||
|
||||
$('.o_searchview_input').val("she was born in a hurricane").trigger('keyup');
|
||||
await testUtils.nextTick();
|
||||
|
||||
messageFetchCount = 1;
|
||||
$('.o_searchview_input').trigger($.Event('keydown', { which: $.ui.keyCode.ENTER }));
|
||||
await testUtils.nextTick();
|
||||
|
||||
await testUtils.dom.click(discuss.$('.o_favorites_menu_button'));
|
||||
await testUtils.dom.click(discuss.$('.o_add_favorite'));
|
||||
|
||||
await testUtils.fields.editInput(discuss.$('.o_favorite_name input'), 'War');
|
||||
await testUtils.dom.click(discuss.$('.o_save_favorite button'));
|
||||
|
||||
discuss.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,6 +34,15 @@ var ActionMixin = {
|
||||
*/
|
||||
contentTemplate: null,
|
||||
|
||||
/**
|
||||
* Events built by and managed by Odoo Framework
|
||||
*
|
||||
* It is expected that any Widget Class implementing this mixin
|
||||
* will also implement the ParentedMixin which actually manages those
|
||||
*/
|
||||
custom_events: {
|
||||
get_controller_query_params: '_onGetControllerQueryParams',
|
||||
},
|
||||
/**
|
||||
* If an action wants to use a control panel, it will be created and
|
||||
* registered in this _controlPanel key (the widget). The way this control
|
||||
@@ -178,6 +187,21 @@ var ActionMixin = {
|
||||
this._title = title;
|
||||
this.updateControlPanel({title: this._title}, {clear: false});
|
||||
},
|
||||
/**
|
||||
* FIXME: this logic should be rethought
|
||||
*
|
||||
* Handles a context request: provides to the caller the state of the
|
||||
* current controller.
|
||||
*
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {function} ev.data.callback used to send the requested state
|
||||
*/
|
||||
_onGetControllerQueryParams: function (ev) {
|
||||
ev.stopPropagation();
|
||||
var state = this.getOwnedQueryParams();
|
||||
ev.data.callback(state || {});
|
||||
},
|
||||
};
|
||||
|
||||
return ActionMixin;
|
||||
|
||||
@@ -24,14 +24,13 @@ var session = require('web.session');
|
||||
var QWeb = core.qweb;
|
||||
|
||||
var AbstractController = mvc.Controller.extend(ActionMixin, {
|
||||
custom_events: {
|
||||
get_controller_query_params: '_onGetControllerQueryParams',
|
||||
custom_events: _.extend({}, ActionMixin.custom_events, {
|
||||
navigation_move: '_onNavigationMove',
|
||||
open_record: '_onOpenRecord',
|
||||
search: '_onSearch',
|
||||
switch_view: '_onSwitchView',
|
||||
search_panel_domain_updated: '_onSearchPanelDomainUpdated',
|
||||
},
|
||||
}),
|
||||
events: {
|
||||
'click a[type="action"]': '_onActionClicked',
|
||||
},
|
||||
@@ -546,21 +545,6 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* FIXME: this logic should be rethought
|
||||
*
|
||||
* Handles a context request: provides to the caller the state of the
|
||||
* current controller.
|
||||
*
|
||||
* @private
|
||||
* @param {OdooEvent} ev
|
||||
* @param {function} ev.data.callback used to send the requested state
|
||||
*/
|
||||
_onGetControllerQueryParams: function (ev) {
|
||||
ev.stopPropagation();
|
||||
var state = this.getOwnedQueryParams();
|
||||
ev.data.callback(state || {});
|
||||
},
|
||||
/**
|
||||
* Called either from the control panel to focus the controller
|
||||
* or from the view to focus the search bar
|
||||
|
||||
Reference in New Issue
Block a user