[FIX] web: load_filters in search dialogs
Since fbf347498f, when opening a view in a
dialog, the favorite filters were not loaded.
For example on the runbot:
1. In CRM, open any lead, edit it, and open the Customer dropdown
2. Create a custom filter, save it as favorite, and close the dialog
3. Open the dialog again: you don't see your new filter
With this commit, you will see your filter at step nr. 3
closes odoo/odoo#59186
X-original-commit: 418013e8dbb2aa2d4ffd4f650f080ca5a94183f9
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
This commit is contained in:
@@ -335,7 +335,7 @@ var SelectCreateDialog = ViewDialog.extend({
|
||||
var _super = this._super.bind(this);
|
||||
var viewRefID = this.viewType === 'kanban' ?
|
||||
(this.options.kanban_view_ref && JSON.parse(this.options.kanban_view_ref) || false) : false;
|
||||
return this.loadViews(this.res_model, this.context, [[viewRefID, this.viewType], [false, 'search']], {})
|
||||
return this.loadViews(this.res_model, this.context, [[viewRefID, this.viewType], [false, 'search']], {load_filters: true})
|
||||
.then(this.setup.bind(this))
|
||||
.then(function (fragment) {
|
||||
self.opened().then(function () {
|
||||
|
||||
@@ -580,5 +580,46 @@ odoo.define('web.favorite_menu_tests', function (require) {
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('modal loads saved search filters', async function (assert) {
|
||||
assert.expect(1);
|
||||
const data = {
|
||||
partner: {
|
||||
fields: {
|
||||
bar: { string: "Bar", type: "many2one", relation: 'partner' },
|
||||
},
|
||||
// 10 records so that the Search button shows
|
||||
records: Array.apply(null, Array(10)).map(function(_, i) {
|
||||
return { id: i, display_name: "Record " + i, bar: 1 };
|
||||
})
|
||||
},
|
||||
};
|
||||
const form = await createView({
|
||||
arch: `
|
||||
<form string="Partners">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="bar"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>`,
|
||||
data,
|
||||
model: 'partner',
|
||||
res_id: 1,
|
||||
View: FormView,
|
||||
interceptsPropagate: {
|
||||
load_views: function (ev) {
|
||||
assert.ok(ev.data.options.load_filters, "opening dialog should load the filters");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.form.clickEdit(form);
|
||||
|
||||
await testUtils.fields.many2one.clickOpenDropdown('bar');
|
||||
await testUtils.fields.many2one.clickItem('bar', 'Search');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user