summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-03 14:05:48 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-03 14:05:48 +0100
commit55b810dc70cccb23144986d54fd28bb5f91f2b1b (patch)
treea83dda56dac7f02be26f6821dea5b2f1926ea7b0 /addons/web/static/tests/fields/basic_fields_tests.js
parent8bc7cebd9c19ae8f77378d115a8401d7b7de56b0 (diff)
parent726b91b9fbc994c6b2f2cb45e36d4c224497f11b (diff)
[MERGE] forward port branch saas-11.1 up to 726b91b9fbc
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js57
1 files changed, 57 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 08e255777eb..6a67cc43736 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2457,6 +2457,63 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('monetary field with currency digits != 2', function (assert) {
+ assert.expect(5);
+
+ this.data.partner.records = [{
+ id: 1,
+ bar: false,
+ foo: "pouet",
+ int_field: 68,
+ qux: 99.1234,
+ currency_id: 1,
+ }];
+ this.data.currency.records = [{
+ id: 1,
+ display_name: "VEF",
+ symbol: "Bs.F",
+ position: "after",
+ digits: [16, 4],
+ }];
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners">' +
+ '<sheet>' +
+ '<field name="qux" widget="monetary"/>' +
+ '<field name="currency_id" invisible="1"/>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ session: {
+ currencies: _.indexBy(this.data.currency.records, 'id'),
+ },
+ });
+
+ // Non-breaking space between the currency and the amount
+ assert.strictEqual(form.$('.o_field_widget').first().text(), '99.1234\u00a0Bs.F',
+ 'The value should be displayed properly.');
+
+ form.$buttons.find('.o_form_button_edit').click();
+ assert.strictEqual(form.$('input').first().val(), '99.1234',
+ 'The input should be rendered without the currency symbol.');
+ assert.strictEqual(form.$('input').parent().children().eq(1).text(), 'Bs.F',
+ 'The input should be followed by a span containing the currency symbol.');
+
+ form.$('input').first().val('99.111111111').trigger('input');
+ assert.strictEqual(form.$('input').first().val(), '99.111111111',
+ 'The value should not be formated yet.');
+
+ form.$buttons.find('.o_form_button_save').click();
+ // Non-breaking space between the currency and the amount
+ assert.strictEqual(form.$('.o_field_widget').first().text(), '99.1111\u00a0Bs.F',
+ 'The new value should be rounded properly.');
+
+ form.destroy();
+ });
+
QUnit.test('monetary field in editable list view', function (assert) {
assert.expect(9);