[FIX] survey: submit a survey with empty date
Since rev. odoo/odoo@cd05983 it was not possible to submit a survey if a date field was empty (trying to set `toJSON` on `null`). The datepicker `date` function returns `null` if no date has been selected. opw-1832381
This commit is contained in:
@@ -135,9 +135,11 @@ if(!the_form.length) {
|
||||
for (var i=0; i < date_fields.length; i++) {
|
||||
var el = date_fields[i];
|
||||
var moment_date = $(el).data('DateTimePicker').date();
|
||||
moment_date.toJSON = function () {
|
||||
return this.clone().locale('en').format('YYYY-MM-DD');
|
||||
};
|
||||
if (moment_date) {
|
||||
moment_date.toJSON = function () {
|
||||
return this.clone().locale('en').format('YYYY-MM-DD');
|
||||
};
|
||||
}
|
||||
var field_obj = _.findWhere(formData, {'name': el.name});
|
||||
field_obj.value = JSON.parse(JSON.stringify(moment_date));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user