diff --git a/web_eradicate_duplicate/__openerp__.py b/web_eradicate_duplicate/__openerp__.py index c106311..3fbc4fa 100644 --- a/web_eradicate_duplicate/__openerp__.py +++ b/web_eradicate_duplicate/__openerp__.py @@ -28,10 +28,12 @@ 'license': 'AGPL-3', 'summary': 'Remove More > Duplicate for all users except admin', 'description': ''' -Eradicate duplicate +Eradicate Duplicate =================== -This module is inspired by the module *web_hide_duplicate* of Aristobulo Meneses available on https://github.com/menecio/odoo-addons. The main difference is that it will remove the *More > Duplicate* button everywhere (without any change in the XML of the form views) for all users except *admin*. +This module is inspired by the module *web_hide_duplicate* of Aristobulo Meneses available on https://github.com/menecio/odoo-addons. The main difference is that it will remove the *More > Duplicate* button everywhere by default for all users except *admin*. + +It is possible to restore the duplicate feature on some form views by adding an attribute **duplicate_eradicate="false"** (you will find an example in a comment at the end of the file static/src/js/eradicate_duplicate.js). This module has been written by Alexis de Lattre from Akretion . diff --git a/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js b/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js index 429b0f5..bf417d8 100644 --- a/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js +++ b/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js @@ -10,7 +10,14 @@ openerp.web_eradicate_duplicate = function (instance) { load_form: function(data) { this._super(data); // Remove More > Duplicate button for all users except admin - if (this.session.uid != 1 && this.sidebar && this.sidebar.items && this.sidebar.items.other) { + // or except if there is an attribute duplicate_eradicate="false" + // in the form view + if ( + this.sidebar && + this.sidebar.items && + this.sidebar.items.other && + this.session.uid != 1 && + this.is_action_enabled('eradicate_duplicate')) { var new_items_other = _.reject(this.sidebar.items.other, function (item) { return item.label === _t('Duplicate'); }); @@ -19,3 +26,20 @@ openerp.web_eradicate_duplicate = function (instance) { } }); }; + +/* + +EXAMPLE : enable duplicate on account.move : + + + duplicate_allowed.account_move_form + account.move + + + + false + + + + +*/