Skip to content
Snippets Groups Projects
Commit 27d649e8 authored by Lucas Perais (lpe)'s avatar Lucas Perais (lpe)
Browse files

[FIX] web: custom filter on date[time] with changing the operator


On a list view, Add a custom filter on a date
Change the operator to "in between"
Change it back to "equal"
Apply the search

Before this commit, the label of the filter still was in between
Whereas it should have been "equal to ..."

After this commit, the label of the filter is correct

OPW 2085951

closes odoo/odoo#38705

Signed-off-by: default avatarLucas Perais (lpe) <lpe@odoo.com>
parent 88e193ee
No related branches found
No related tags found
No related merge requests found
......@@ -242,7 +242,8 @@ var DateTime = Field.extend({
},
toString: function () {
var str = field_utils.format[this.attributes.type](this.get_value(), {type: this.attributes.type});
var date_1_value = this.datewidget_1 && this.get_value(1);
// the second datewidget might have been hidden because the operator has changed
var date_1_value = this.datewidget_1 && !this.datewidget_1.$el.hasClass('o_hidden') && this.get_value(1);
if (date_1_value) {
str += _lt(" and ") + field_utils.format[this.attributes.type](date_1_value, {type: this.attributes.type});
}
......
......@@ -686,7 +686,7 @@ QUnit.module('Search View', {
actionManager.destroy();
});
QUnit.test('Custom Filter datetime with equal operator', function (assert) {
QUnit.test('Custom Filter datetime with equal operator, operator has been changed', function (assert) {
assert.expect(5);
this.data.partner.fields.date_time_field = {string: "DateTime", type: "datetime", store: true, searchable: true};
......@@ -724,6 +724,14 @@ QUnit.module('Search View', {
assert.strictEqual($('.o_dropdown_menu select.o_searchview_extended_prop_op').val(), '=',
'The equal operator is selected');
// Change operator, and back
$('.o_dropdown_menu select.o_searchview_extended_prop_op').val('between').trigger('change');
assert.strictEqual($('.o_dropdown_menu select.o_searchview_extended_prop_op').val(), 'between',
'The between operator is selected');
$('.o_dropdown_menu select.o_searchview_extended_prop_op').val('=').trigger('change');
$('.o_searchview_extended_prop_value input').val('02/22/2017 11:00:00').trigger('change'); // in TZ
searchReadCount = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment