summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2018-10-09 16:00:47 +0000
committerMartin Trigaux <mat@odoo.com>2018-10-10 13:59:36 +0000
commit0aa0cec97ac8f751c0256f70563f1378244cde41 (patch)
tree1248c0b29c1f610628476055d04e52eeac49e2ab /addons/web/static/tests/fields/basic_fields_tests.js
parent5c6edfc8d339d010bccf6e4426e315e911b21ee5 (diff)
[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
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js34
1 files changed, 34 insertions, 0 deletions
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:'<form string="Partners">' +
+ '<field name="date" options="{\'datepicker\': {\'warn_future\': true}}"/>' +
+ '</form>',
+ 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);