summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorJulien (juc) Castiaux <juc@odoo.com>2019-01-16 15:26:18 +0000
committerJulien (juc) Castiaux <juc@odoo.com>2019-01-30 08:25:27 +0000
commitb6f11ace836e946eeeae110cdb08d16d80546238 (patch)
treebb88b647d37e98c771da58a547ac2ba4c9b563c1 /addons/web/static/tests/fields/basic_fields_tests.js
parente13d449f31d0ff7b6b4d47ed49e1cea4006916a5 (diff)
[FIX] web: datepicker fallbacks to default english locale
When using the datepicker with norwegian locales, the dates are correctly formatted using the norwegian locale but the name of the months are shown in english. This cause a date validation error and thus it is not possible to change the date. tempusdominus.js uses moment.js to deal with dates, it sometimes copies/creates some and set their option according to the ones given at instantiation time and fallbacks on default options for that are not set. opw-1922437 closes odoo/odoo#30276
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index cb49e8b5bba..978e6de226f 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2969,6 +2969,47 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('date field support internalization', function (assert) {
+ assert.expect(2);
+
+ var originalLocale = moment.locale();
+ var originalParameters = _.clone(core._t.database.parameters);
+
+ _.extend(core._t.database.parameters, {date_format: '%d. %b %Y', time_format: '%H:%M:%S'});
+ moment.defineLocale('norvegianForTest', {
+ monthsShort: 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
+ monthsParseExact: true,
+ dayOfMonthOrdinalParse: /\d{1,2}\./,
+ ordinal: '%d.',
+ });
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners"><field name="date"/></form>',
+ res_id: 1,
+ });
+
+ var dateViewForm = form.$('.o_field_date').text();
+ testUtils.dom.click(form.$buttons.find('.o_form_button_edit'));
+ testUtils.openDatepicker(form.$('.o_datepicker'));
+ assert.strictEqual(form.$('.o_datepicker_input').val(), dateViewForm,
+ "input date field should be the same as it was in the view form");
+
+ testUtils.dom.click($('.day:contains(30)'));
+ var dateEditForm = form.$('.o_datepicker_input').val()
+ testUtils.dom.click(form.$buttons.find('.o_form_button_save'));
+ assert.strictEqual(form.$('.o_field_date').text(), dateEditForm,
+ "date field should be the same as the one selected in the view form");
+
+ moment.locale(originalLocale);
+ moment.updateLocale('norvegianForTest', null);
+ core._t.database.parameters = originalParameters;
+
+ form.destroy();
+ });
+
QUnit.module('FieldDatetime');
QUnit.test('datetime field in form view', function (assert) {