summaryrefslogtreecommitdiff
path: root/addons/website_form/static
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2020-09-03 14:24:57 +0000
committerNicolas Lempereur <nle@odoo.com>2020-09-08 07:20:16 +0000
commitf44d580cc665848c228d96dfb7a4e95dfa96c25c (patch)
tree8f74c4b439474cc6b8594ab235fb7bd786b78922 /addons/website_form/static
parentb1236c731da4c59a211c506b164a5d934ef6bc4a (diff)
[FIX] website_form: lang arabic for date/datetime
When we send dates with website_form, if the language of the website is eg. in arabic we will send moment.js arabic dates that can't be parsed by the server. This also happens with norwegian and any language which doesn't use ascii numbers or textual format of month or days (and possibly RTL language). With this changeset, if we detect we are in a use case where this matter (an existing field and a date format that will fail) the date will be sent as odoo server format. Expected change: - what worked still work with or without server restart - what didn't work works after server restart - special case such as "english" with custom format in res.language containing textual month might now not work with code update without server restart (probability of this is low). opw-2326882 closes #57042 closes odoo/odoo#57214 Note: the saas-13.5 version always force isoformat for existing fields X-original-commit: 9a5bb5e892bc40709fab77c2bc62adcba19e02d2 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/website_form/static')
-rw-r--r--addons/website_form/static/src/snippets/s_website_form/000.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/website_form/static/src/snippets/s_website_form/000.js b/addons/website_form/static/src/snippets/s_website_form/000.js
index b2f0f3370b4..573656d5b92 100644
--- a/addons/website_form/static/src/snippets/s_website_form/000.js
+++ b/addons/website_form/static/src/snippets/s_website_form/000.js
@@ -141,6 +141,18 @@ odoo.define('website_form.s_website_form', function (require) {
}
});
+ // force server date format usage for existing fields
+ this.$target.find('.s_website_form_field:not(.s_website_form_custom)')
+ .find('.s_website_form_date, .s_website_form_datetime').each(function () {
+ var date = $(this).datetimepicker('viewDate').clone().locale('en');
+ var format = 'YYYY-MM-DD';
+ if ($(this).hasClass('s_website_form_datetime')) {
+ date = date.utc();
+ format = 'YYYY-MM-DD HH:mm:ss';
+ }
+ form_values[$(this).find('input').attr('name')] = date.format(format);
+ });
+
const tokenObj = await this._recaptcha.getToken('website_form');
if (tokenObj.token) {
form_values['recaptcha_token_response'] = tokenObj.token;