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"); + }); + });});