From 076fdb09940c57c385c3b3f7639bb893464afb69 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 14 Aug 2012 18:38:21 +0530 Subject: [PATCH] [IMP] views should show the button create/edit/delete/duplicate on the view tag create/edit/delete attributes bzr revid: jam@tinyerp.com-20120814130821-ret2z62dsthle39p --- addons/web/static/src/js/view_form.js | 15 +++++++++++++-- addons/web/static/src/js/view_list.js | 11 +++++++++-- addons/web/static/src/xml/base.xml | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index baf8c151b83..2e800191749 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -148,9 +148,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if(this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: self.on_button_delete }, + ]); + } + if (self._is_action_enabled('create')){ + this.sidebar.add_items('other', [ + { label: _t('Duplicate'), callback: self.on_button_duplicate } + ]); + } this.sidebar.add_items('other', [ - { label: _t('Delete'), callback: self.on_button_delete }, - { label: _t('Duplicate'), callback: self.on_button_duplicate }, { label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } } ]); } @@ -1042,6 +1050,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM open_translate_dialog: function(field) { return this._super(field); }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; + } }); /** diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 986b0e49faf..3d6ec27d065 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -353,9 +353,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.appendTo(this.options.$sidebar); this.sidebar.add_items('other', [ { label: _t("Import"), callback: this.on_sidebar_import }, - { label: _t("Export"), callback: this.on_sidebar_export }, - { label: _t('Delete'), callback: this.do_delete_selected } + { label: _t("Export"), callback: this.on_sidebar_export } ]); + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: this.do_delete_selected } + ]); + } this.sidebar.add_toolbar(this.fields_view.toolbar); this.sidebar.$element.hide(); } @@ -831,6 +835,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$element.prepend( $('
').html(this.options.action.help) ); + }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.ListView.List# */{ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0eddd914f01..21d006e23ab 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -672,9 +672,11 @@
- + + + or Import @@ -747,10 +749,14 @@
-
- -
+ +
+ +
+
+ +
or Discard