[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
This commit is contained in:
Jigar Amin - OpenERP 2012-08-14 18:38:21 +05:30
parent 3e797902fc
commit 076fdb0994
3 changed files with 34 additions and 10 deletions

View File

@ -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;
}
});
/**

View File

@ -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(
$('<div class="oe_view_nocontent">').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# */{

View File

@ -672,9 +672,11 @@
</table>
<div t-name="ListView.buttons" class="oe_list_buttons">
<t t-if="!widget.no_leaf and widget.options.action_buttons !== false and widget.options.addable">
<button type="button" class="oe_button oe_list_add oe_highlight">
<t t-esc="widget.options.addable"/>
</button>
<t t-if="widget._is_action_enabled('create')">
<button type="button" class="oe_button oe_list_add oe_highlight">
<t t-esc="widget.options.addable"/>
</button>
</t>
<span class="oe_alternative" t-if="widget.options.import_enabled">
<span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a>
</span>
@ -747,10 +749,14 @@
<div t-name="FormView.buttons" class="oe_form_buttons">
<t t-if="widget.options.action_buttons !== false">
<span class="oe_form_buttons_view">
<div style="display: inline-block;"> <!-- required for the bounce effect on button -->
<button type="button" class="oe_button oe_form_button_edit">Edit</button>
</div>
<t t-if="widget._is_action_enabled('edit')">
<div style="display: inline-block;"> <!-- required for the bounce effect on button -->
<button type="button" class="oe_button oe_form_button_edit">Edit</button>
</div>
</t>
<t t-if="widget._is_action_enabled('create')">
<button type="button" class="oe_button oe_form_button_create">Create</button>
</t>
</span>
<span class="oe_form_buttons_edit">
<button type="button" class="oe_button oe_form_button_save oe_highlight">Save</button> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_form_button_cancel">Discard</a>