From 1a9a082d10232b2aeb11c210db992de15255fcd1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 17 Feb 2017 18:14:48 +0100 Subject: [PATCH] [FIX] web: create="0" in many2many list views The revision dd657c42f7cbac01294ef794bf0e697ed495c722 intended to give the possibility to add an existing record to a many2many list even without the `create` access on the model of this record. This is accepted by the ORM, as there is no need of the create right on the model, only the write on the source model on which the many2many field is. The revision has as unexpected side effect to remove the possibility to manually set `create="0"` on the tree of a many2many field, to hide the "add an item" of the list view. As this last feature is more important, we therefore revert this. We will provide another solution for the above issue. We think about forcing what the view definition says, so if you set create="1" on the view, it will display the "add an item" link in any case, even if you do not have the access right to do it. This would allow to display the link for the above case, and in case you actually do not have the access right, and this is an error in the view definition, you will have an access error raised anyway. opw-708310 --- addons/web/static/src/js/views/form_relational_widgets.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 06bca6cd382..6a6c258f8f9 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -997,9 +997,7 @@ var X2ManyListView = ListView.extend({ */ var X2ManyList = ListView.List.extend({ pad_table_to: function (count) { - var ftype = this.view.x2m.field.type; - var is_readonly = this.view.x2m.get('effective_readonly'); - if (is_readonly || (ftype === 'one2many' && !this.view.is_action_enabled('create'))) { + if (!this.view.is_action_enabled('create') || this.view.x2m.get('effective_readonly')) { this._super(count); return; }