[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.
This commit is contained in:
Géry Debongnie
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent dba7e64a2f
commit 1a7fbd5a13
2 changed files with 37 additions and 0 deletions
@@ -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,
@@ -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: '<form>' +
'<div name="button_box" class="oe_button_box">' +
'<button type="object" class="oe_stat_button" icon="fa-check-square">' +
'<field name="bar" widget="boolean_button" options=\'{"terminology": ' +
JSON.stringify(terminology) + '}\'/>' +
'</button>' +
'</div>' +
'</form>',
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");
});
});});