[FIX] web: Error on invalid date format on date field input

Steps to reproduce the bug:

- Go to any field Date
- Enter wrong date

Bug:
A traceback was raised.

Now a warning is raised and the wrong value is removed.

opw:1974747

closes odoo/odoo#33362

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-05-15 06:36:08 +00:00
parent c3a81c6c7e
commit 9ed9710b2b
2 changed files with 29 additions and 0 deletions
@@ -2667,6 +2667,25 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test('date field should remove the date if the date is not valid', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners"><field name="date"/></form>',
res_id: 4,
});
// switch to edit mode
form.$buttons.find('.o_form_button_edit').click();
// set an invalid date
var $input = form.$('.o_field_widget[name=date] input');
$input.val('mmmh').trigger('change');
assert.strictEqual($input.text(), "", "The date field should be empty");
form.destroy();
});
QUnit.test('date field value should not set on first click', function (assert) {
assert.expect(2);