Permalink
Browse files

[FIX] web: timerange menu: descriptions are strings

On a view, define a timerange for fetching data
Save as favorite

Before this commit, the time range description were not transmitted as
strings for the creation of the filter
So, when loading the filter back, there was no description for column headers
resulting in displaying "Object [Object]" as their title

After this commit, we save in the context of the filter the description of the title

OPW 1930582
  • Loading branch information...
kebeclibre committed Feb 11, 2019
1 parent 785e5f1 commit 1c5634e2bab95bdc1d8630ae2ec7bb64408531e5
@@ -103,10 +103,12 @@ var TimeRangeMenu = Widget.extend({
this.timeRangeId,
this.dateField.type
);
timeRangeDescription = _.findWhere(
var rawDescriptionRange = _.findWhere(
this.periodOptions,
{optionId: this.timeRangeId}
).description;
// the attribute is a lazy loaded translation
timeRangeDescription = rawDescriptionRange.toString ? rawDescriptionRange.toString() : rawDescriptionRange;
}
if (this.comparisonIsSelected) {
comparisonTimeRange = Domain.prototype.constructDomain(
@@ -116,10 +118,12 @@ var TimeRangeMenu = Widget.extend({
null,
this.comparisonTimeRangeId
);
comparisonTimeRangeDescription = _.findWhere(
var rawDescriptionCompare = _.findWhere(
this.comparisonOptions,
{optionId: this.comparisonTimeRangeId}
).description;
// the attribute is a lazy loaded translation
comparisonTimeRangeDescription = rawDescriptionCompare.toString ? rawDescriptionCompare.toString() : rawDescriptionCompare;
}
}

@@ -1379,7 +1379,7 @@ QUnit.module('Views', {
});

QUnit.test('rendering of pivot view with comparison', function (assert) {
assert.expect(91);
assert.expect(92);

this.data.partner.records[0].date = '2016-12-15';
this.data.partner.records[1].date = '2016-12-17';
@@ -1416,6 +1416,17 @@ QUnit.module('Views', {
'</pivot>',
'partner,false,search': '<search></search>',
},
intercepts: {
create_filter: function (ev) {
var data = ev.data;
assert.deepEqual(data.filter.context.timeRangeMenuData, {
timeRange: ["&",["date",">=","2016-12-01"],["date","<","2017-01-01"]],
timeRangeDescription: 'This Month',
comparisonTimeRange: ["&",["date",">=","2016-11-01"],["date","<","2016-12-01"]],
comparisonTimeRangeDescription: 'Previous Period',
});
}
}
});

actionManager.doAction({
@@ -1487,6 +1498,12 @@ QUnit.module('Views', {
];
checkCellValues(results);

$('.o_search_options button:contains("Favorites")').click();
var $favorites = $('.dropdown-menu.o_favorites_menu');
$favorites.find('a.o_save_search').click();
$favorites.find('.o_input').val('Fav').trigger('input');
$favorites.find('button').click();

unpatchDate();
actionManager.destroy();
});

0 comments on commit 1c5634e

Please sign in to comment.