From 00a172b40d0fd7edbf7cd7190b2e9db6345e51b5 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 3 Mar 2017 14:01:13 +0100 Subject: [PATCH] [FIX] web: adapt 1a9a082d to new fields --- .../static/src/js/fields/relational_fields.js | 22 +------------------ .../test/fields/relational_fields_tests.js | 6 ++--- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 3f20d802209..b3b3a26c437 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -566,16 +566,6 @@ var FieldX2Many = AbstractRelationalField.extend({ // Private //-------------------------------------------------------------------------- - /** - * This function is meant to be overriden by the One2ManyField. - * - * @private - * @returns {Boolean} true if the 'Add an item' row should be available in - * the list renderer, false otherwise - */ - _hasCreateLine: function () { - return !this.isReadonly; - }, /** * Instanciates or updates the adequate renderer. * @@ -597,7 +587,7 @@ var FieldX2Many = AbstractRelationalField.extend({ this.renderer = new ListRenderer(this, this.value, { arch: arch, mode: this.mode, - addCreateLine: this._hasCreateLine(), + addCreateLine: !this.isReadonly && this.activeActions.create, addTrashIcon: !this.isReadonly, }); } @@ -784,16 +774,6 @@ var FieldOne2Many = FieldX2Many.extend({ // Private //-------------------------------------------------------------------------- - /** - * Overrides enable the 'Add an item' feature if the 'create' action is - * available. - * - * @override - * @private - */ - _hasCreateLine: function () { - return this._super.apply(this, arguments) && this.activeActions.create; - }, /** * Overrides to only render the buttons if the 'create' action is available. * diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js index b306c52d0f8..af4a1d9ee18 100644 --- a/addons/web/static/test/fields/relational_fields_tests.js +++ b/addons/web/static/test/fields/relational_fields_tests.js @@ -2035,11 +2035,9 @@ QUnit.module('relational_fields', { form.$buttons.find('.o_form_button_edit').click(); - assert.ok(form.$('.o_form_field_x2many_list_row_add').length, - '"Add an item" link should be available in edit'); + assert.ok(!form.$('.o_form_field_x2many_list_row_add').length, + '"Add an item" link should not be available in edit either'); - // TODO: click on add an item and test that the select create dialog has no 'Create' button - // form.$('.o_form_field_x2many_list_row_add').click(); form.destroy(); });