[IMP] web: add 'Last 5 Years' as a period option
This commit adds the option 'Last 5 Years' in the list of periods available to selection in the filter menu and the time range menu for the date/datetime fields. Task: 1916017 closes odoo/odoo#29423
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
parent
d132870cab
commit
bd0e0605cc
@@ -359,6 +359,11 @@ var Domain = collections.Tree.extend({
|
||||
rightBoundaryParams = t ? {days: -1} : {};
|
||||
offsetPeriodParams = {days: -365};
|
||||
return makeInterval();
|
||||
case 'last_5_years':
|
||||
leftBoundaryParams = {years: -5};
|
||||
rightBoundaryParams = t ? {days: -1} : {};
|
||||
offsetPeriodParams = {years: -5};
|
||||
return makeInterval();
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ var PERIOD_OPTIONS = [
|
||||
{description: _lt('Last 7 Days'), optionId: 'last_7_days', groupId: 1},
|
||||
{description: _lt('Last 30 Days'), optionId: 'last_30_days', groupId: 1},
|
||||
{description: _lt('Last 365 Days'), optionId: 'last_365_days', groupId: 1},
|
||||
{description: _lt('Last 5 Years'), optionId: 'last_5_years', groupId: 1},
|
||||
{description: _lt('Today'), optionId: 'today', groupId: 2},
|
||||
{description: _lt('This Week'), optionId: 'this_week', groupId: 2},
|
||||
{description: _lt('This Month'), optionId: 'this_month', groupId: 2},
|
||||
|
||||
@@ -209,6 +209,8 @@ QUnit.module('Search View', {
|
||||
['&', ["date_field", ">=", "2017-02-20"],["date_field", "<", "2017-03-22"]],
|
||||
// last 365 days
|
||||
['&', ["date_field", ">=", "2016-03-22"],["date_field", "<", "2017-03-22"]],
|
||||
// last 5 years
|
||||
['&', ["date_field", ">=", "2012-03-22"],["date_field", "<", "2017-03-22"]],
|
||||
// today
|
||||
['&', ["date_field", ">=", "2017-03-22"],["date_field", "<", "2017-03-23"]],
|
||||
// this week
|
||||
@@ -239,6 +241,8 @@ QUnit.module('Search View', {
|
||||
['&', ["date_field", ">=", "2017-01-21"],["date_field", "<", "2017-02-20"]],
|
||||
// last 365 days
|
||||
['&', ["date_field", ">=", "2015-03-23"],["date_field", "<", "2016-03-22"]],
|
||||
// last 5 years
|
||||
['&', ["date_field", ">=", "2007-03-22"],["date_field", "<", "2012-03-22"]],
|
||||
// today - 1 day
|
||||
['&', ["date_field", ">=", "2017-03-21"],["date_field", "<", "2017-03-22"]],
|
||||
// this week - 1 week
|
||||
@@ -637,7 +641,7 @@ QUnit.module('Search View', {
|
||||
});
|
||||
|
||||
QUnit.test('filter by a date field using period works', function (assert) {
|
||||
assert.expect(14);
|
||||
assert.expect(15);
|
||||
|
||||
var self = this;
|
||||
|
||||
@@ -678,14 +682,13 @@ QUnit.module('Search View', {
|
||||
return $(this).data('option_id');
|
||||
}).toArray();
|
||||
|
||||
|
||||
|
||||
assert.deepEqual(periodOptions, PERIOD_OPTIONS_IDS,
|
||||
"13 period options should be available:");
|
||||
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="last_7_days"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="last_30_days"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="last_365_days"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="last_5_years"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="today"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="this_week"]'));
|
||||
testUtils.dom.click($('.o_menu_item .o_item_option[data-option_id="this_month"]'));
|
||||
@@ -1112,7 +1115,7 @@ QUnit.module('Search View', {
|
||||
});
|
||||
|
||||
QUnit.test('time range menu in comparison mode', function (assert) {
|
||||
assert.expect(43);
|
||||
assert.expect(46);
|
||||
|
||||
var self = this;
|
||||
var nbrReadGroup = 0;
|
||||
|
||||
Reference in New Issue
Block a user