From 0aa0cec97ac8f751c0256f70563f1378244cde41 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 9 Oct 2018 16:00:47 +0000 Subject: [FIX] web: do not warn on empty field If no value is specified on the datefield, do not set a warnfuture message Remove code comment that was referring the condition present at b51b0d66c2f7 but no longer present. Add tests Fixes #27551 closes odoo/odoo#27593 --- .../web/static/tests/fields/basic_fields_tests.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index c1d51b3a1c5..7db578b5d4e 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2590,6 +2590,40 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('date field with warn_future option', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '', + res_id: 4, + }); + + // switch to edit mode + form.$buttons.find('.o_form_button_edit').click(); + // open datepicker and select another value + testUtils.openDatepicker(form.$('.o_datepicker')); + $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection + $('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Year selection + $('.bootstrap-datetimepicker-widget .year').eq(11).click(); // last year + $('.bootstrap-datetimepicker-widget .month').eq(11).click(); // December + $('.day:contains(31)').click(); // select the 31 December + + var $warn = form.$('.o_datepicker_warning:visible'); + assert.strictEqual($warn.length, 1, "should have a warning in the form view"); + + form.$('.o_field_widget[name=date] input').val('').trigger('change'); // remove the value + + $warn = form.$('.o_datepicker_warning:visible'); + assert.strictEqual($warn.length, 0, "the warning in the form view should be hidden"); + + form.destroy(); + }); + QUnit.test('date field in editable list view', function (assert) { assert.expect(8); -- cgit v1.2.3