diff options
| author | Nasreddin (bon) <bon@odoo.com> | 2021-04-19 20:06:42 +0000 |
|---|---|---|
| committer | Nasreddin Boulif (bon) <bon@odoo.com> | 2021-05-11 23:21:51 +0000 |
| commit | f3c5dd794e4de71187fd7532c39595b2297eb93d (patch) | |
| tree | 4682473e7876147b961ce69907176be3515a1cfa /addons/survey/static/src/js | |
| parent | 9f6b5b889b9402a391a1215c44ce2c5501e1b5de (diff) | |
[FIX] survey: display right date format in datepicker
Issue
- Install 'Survey' & 'website' module
- Enable "es_VE" language and activate on main website
- Go to Website Homepage
- Switch to "Spanish (VE)" language (footer)
- Go to "Survey" module
- Create a survey:
- Add a question of type 'Date' then save
- Click on "TEST" button
- Start survey and add a date with the datepicker
- Submit survey
Error message : 'This is not a date'
Cause
When submit survey, not using the database date format.
Solution
When validating form (on submit), check if date is formated
with database format and (not the moment locale since user can
alter date and datetime format).
opw-2452237
closes odoo/odoo#70273
X-original-commit: ddfcecc6c3d013532d06409633a37e653cc05e0f
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
Diffstat (limited to 'addons/survey/static/src/js')
| -rw-r--r-- | addons/survey/static/src/js/survey_form.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/survey/static/src/js/survey_form.js b/addons/survey/static/src/js/survey_form.js index e789230e06b..e0e12c1c256 100644 --- a/addons/survey/static/src/js/survey_form.js +++ b/addons/survey/static/src/js/survey_form.js @@ -589,7 +589,8 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({ if (questionRequired && !data[questionId]) { errors[questionId] = constrErrorMsg; } else if (data[questionId]) { - var momentDate = moment($input.val()); + var datetimepickerFormat = $input.data('questionType') === 'datetime' ? time.getLangDatetimeFormat() : time.getLangDateFormat(); + var momentDate = moment($input.val(), datetimepickerFormat); if (!momentDate.isValid()) { errors[questionId] = validationDateMsg; } else { |
