[FIX] web: only default time range works
If a default time range was set in the action but no other default filter or groupby, the time range wasn't applied. This commit fixes that situation.
This commit is contained in:
@@ -483,7 +483,7 @@ var SearchView = Widget.extend({
|
||||
this.hasFavorites = true;
|
||||
return this.favorite_menu.toggle_filter(default_custom_filter, true);
|
||||
}
|
||||
if (!_.isEmpty(this.search_defaults)) {
|
||||
if (!_.isEmpty(this.search_defaults) || this.timeRanges) {
|
||||
var inputs = this.search_fields.concat(this.filters, this.groupbys);
|
||||
var search_defaults = _.invoke(inputs, 'facet_for_defaults', this.search_defaults);
|
||||
var defaultTimeRange = this._searchDefaultTimeRange();
|
||||
|
||||
@@ -787,5 +787,32 @@ QUnit.module('Search View', {
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('a default time range only in context is taken into account', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var actionManager = createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data,
|
||||
mockRPC: function (route, args) {
|
||||
// there are two read_group calls (for the groupby lists [] and ["date_field:day"])
|
||||
if (route === '/web/dataset/call_kw/partner/read_group') {
|
||||
var timeRangeMenuData = args.kwargs.context.timeRangeMenuData;
|
||||
assert.ok(timeRangeMenuData.timeRange.length > 0, "time range should be non empty");
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
actionManager.doAction({
|
||||
res_model: 'partner',
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[false, 'pivot']],
|
||||
context: {time_ranges: {range: 'today', field: 'date_field'}}
|
||||
});
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user