From 1a7fbd5a13fe8d9c6d47fb49204061b002240ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sat, 25 Feb 2017 09:33:19 +0100 Subject: [PATCH] [FIX] web: make sure form view properly transmit attrs When creating a new record, the form view did not properly transmit the attrs to the new record. --- .../src/js/views/form/form_controller.js | 1 + addons/web/static/test/views/form_tests.js | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index c1824223849..3dde4fd5088 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -56,6 +56,7 @@ var FormController = BasicController.extend({ var record = this.model.get(this.handle, {raw: true}); return this.model.makeDefaultRecord(this.modelName, { context: this.context, + fieldAttrs: record.fieldAttrs, fieldNames: record.fieldNames, fields: record.fields, res_ids: record.res_ids, diff --git a/addons/web/static/test/views/form_tests.js b/addons/web/static/test/views/form_tests.js index bcfbb4c32f5..55b41e5f842 100644 --- a/addons/web/static/test/views/form_tests.js +++ b/addons/web/static/test/views/form_tests.js @@ -1596,4 +1596,40 @@ QUnit.module('Views', { "should have rendered a modal dialog with correct content"); }); + QUnit.test('attrs are properly transmitted to new records', function (assert) { + assert.expect(2); + + // this test checks that the fieldAttrs have been transmitted to the + // load function when creating a new record + + var terminology = { + string_true: "Production Environment", + hover_true: "Switch to test environment", + string_false: "Test Environment", + hover_false: "Switch to production environment" + }; + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '
' + + '' + + '
' + + '
', + res_id: 2, + }); + + assert.strictEqual(form.$('.o_stat_text.o_not_hover:contains(Production Environment)').length, 1, + "button should contain correct string"); + + form.$buttons.find('.o_form_button_create').click(); + + assert.strictEqual(form.$('.o_stat_text.o_not_hover:contains(Test Environment)').length, 1, + "button should contain correct string"); + }); + });});