diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 601133b2e7f..cb7ecddfa82 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2711,6 +2711,12 @@ content: "ö"; color: #404040; } +.openerp .oe_list_cannot_edit .oe_list_header_handle, .openerp .oe_list_cannot_edit .oe_list_field_handle { + display: none !important; +} +.openerp .oe_list_cannot_delete .oe_list_record_delete { + display: none !important; +} .openerp .tree_header { background-color: #f0f0f0; border-bottom: 1px solid #cacaca; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 6ee03494e7d..6fb2c8d21c1 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2072,6 +2072,13 @@ $sheet-max-width: 860px .oe_list_handle @include text-to-icon("ö") + .oe_list_cannot_edit + .oe_list_header_handle, .oe_list_field_handle + display: none !important + .oe_list_cannot_delete + .oe_list_record_delete + display: none !important + // }}} // Tree view {{{ .tree_header diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a53807a9d79..5f13f1c7a93 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -141,14 +141,14 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if (!this.sidebar && this.options.$sidebar) { this.sidebar = new instance.web.Sidebar(this); this.sidebar.appendTo(this.$sidebar); - if(this.fields_view.toolbar) { + if (this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } - this.sidebar.add_items('other', [ - { label: _t('Delete'), callback: self.on_button_delete }, - { label: _t('Duplicate'), callback: self.on_button_duplicate }, + this.sidebar.add_items('other', _.compact([ + self.is_action_enabled('delete') && { label: _t('Delete'), callback: self.on_button_delete }, + self.is_action_enabled('create') && { label: _t('Duplicate'), callback: self.on_button_duplicate }, { label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } } - ]); + ])); } this.has_been_loaded.resolve(); @@ -3473,7 +3473,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments); }, form_view_options: {'not_interactible_on_create':true}, - readonly: self.o2m.get("effective_readonly") + readonly: !this.is_action_enabled('edit') || self.o2m.get("effective_readonly") }); }, do_button_action: function (name, id, callback) { @@ -3561,7 +3561,11 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { - this._super(count > 0 ? count - 1 : 0); + if (!this.view.is_action_enabled('create')) { + this._super(count); + } else { + this._super(count > 0 ? count - 1 : 0); + } // magical invocation of wtf does that do if (this.view.o2m.get('effective_readonly')) { @@ -3574,6 +3578,11 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({ }).length; if (this.options.selectable) { columns++; } if (this.options.deletable) { columns++; } + + if (!this.view.is_action_enabled('create')) { + return; + } + var $cell = $('