[FIX] web: datepicker did not select correct date after initial render

This commit is contained in:
Christophe Matthieu
2017-05-15 16:19:37 +02:00
parent 2e6a1623ff
commit 932e887400
2 changed files with 4 additions and 4 deletions
@@ -56,7 +56,7 @@ var DateWidget = Widget.extend({
var formatted_value = value ? this.format_client(value) : null;
this.$input.val(formatted_value);
if (this.picker) {
this.picker.date(formatted_value);
this.picker.date(value || null);
}
},
get_value: function() {
@@ -95,7 +95,7 @@ var DateWidget = Widget.extend({
//the input field if any or the current day otherwise
var value = moment().second(0);
if(this.$input.val().length !== 0 && this.is_valid()) {
value = this.$input.val();
value = this.parse_client(this.$input.val());
}
this.picker.date(value);
@@ -1257,7 +1257,7 @@ QUnit.module('basic_fields', {
});
QUnit.test('date field in form view', function (assert) {
assert.expect(7);
assert.expect(8);
var form = createView({
View: FormView,
@@ -1290,6 +1290,7 @@ QUnit.module('basic_fields', {
// click on the input and select another value
form.$('.o_datepicker_input').click();
assert.ok(form.$('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
assert.strictEqual(form.$('.day.active').data('day'), '02/03/2017', 'datepicker should be highlight February 3');
form.$('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Month selection
form.$('.bootstrap-datetimepicker-widget .picker-switch').first().click(); // Year selection
form.$('.bootstrap-datetimepicker-widget .year:contains(2017)').click();
@@ -1393,7 +1394,6 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.module('FieldDatetime');
QUnit.test('datetime field in form view', function (assert) {