From ba6a3a91ae78297c7f8ddcf7630ecef46048c15e Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 17 May 2017 09:22:40 +0200 Subject: [FIX] web: MonetaryField: read currency_field in options In the xml definition of views, a 'currency_field' can be specified in the node options: It indicates which field the monetary widget has to use to determine the currency to display. Before this rev., the widget didn't look for the 'currency_field' in the options, but directly in the node attrs, so this simply didn't work. This was for example the case on the crm.lead kanban and form views. --- .../web/static/tests/fields/basic_fields_tests.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 41530f85c4f..ca951506e28 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1769,6 +1769,37 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('monetary field with monetary field given in options', function (assert) { + assert.expect(1); + + this.data.partner.fields.qux.type = "monetary"; + this.data.partner.fields.company_currency_id = { + string: "Company Currency", type: "many2one", relation: "currency", + }; + this.data.partner.records[4].company_currency_id = 2; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '
', + res_id: 5, + session: { + currencies: _.indexBy(this.data.currency.records, 'id'), + }, + }); + + assert.strictEqual(form.$('.o_field_monetary').html(), "9.10 €", + "field monetary should be formatted with correct currency"); + + form.destroy(); + }); + QUnit.test('should keep the focus when being edited in x2many lists', function (assert) { assert.expect(6); -- cgit v1.2.3