[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 b51b0d66c2
but no longer present.

Add tests

Fixes #27551

closes odoo/odoo#27593
This commit is contained in:
Martin Trigaux
2018-10-10 13:59:36 +00:00
parent 5c6edfc8d3
commit 0aa0cec97a
4 changed files with 43 additions and 93 deletions
@@ -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);