From 2ceb626723aff840e1e05de9497aad17b07d7457 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 Jan 2016 23:42:15 +0100 Subject: [PATCH] Add possibility to make an exception on some form views in web_eradicate_duplicate --- web_eradicate_duplicate/__openerp__.py | 6 +++-- .../static/src/js/eradicate_duplicate.js | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) 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 + + + + +*/