diff --git a/web_eradicate_duplicate/__init__.py b/web_eradicate_duplicate/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/web_eradicate_duplicate/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/web_eradicate_duplicate/__openerp__.py b/web_eradicate_duplicate/__openerp__.py new file mode 100644 index 0000000..c106311 --- /dev/null +++ b/web_eradicate_duplicate/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Web Eradicate Duplicate module for Odoo +# Copyright (C) 2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Eradicate Duplicate', + 'version': '8.0.0.1.0', + 'category': 'Tools', + 'license': 'AGPL-3', + 'summary': 'Remove More > Duplicate for all users except admin', + 'description': ''' +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 has been written by Alexis de Lattre from Akretion +. + ''', + 'author': 'Akretion', + 'depends': ['web'], + 'data': ['views/eradicate_duplicate.xml'], + 'installable': True, +} diff --git a/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js b/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js new file mode 100644 index 0000000..429b0f5 --- /dev/null +++ b/web_eradicate_duplicate/static/src/js/eradicate_duplicate.js @@ -0,0 +1,21 @@ +/* Web Eradicate Duplicate + @author: Alexis de Lattre + Inspired by the module web_hide_duplicate of Aristobulo Meneses +*/ + +openerp.web_eradicate_duplicate = function (instance) { + var _t = instance.web._t; + + instance.web.FormView.include({ + 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) { + var new_items_other = _.reject(this.sidebar.items.other, function (item) { + return item.label === _t('Duplicate'); + }); + this.sidebar.items.other = new_items_other; + } + } + }); +}; diff --git a/web_eradicate_duplicate/views/eradicate_duplicate.xml b/web_eradicate_duplicate/views/eradicate_duplicate.xml new file mode 100644 index 0000000..5604c09 --- /dev/null +++ b/web_eradicate_duplicate/views/eradicate_duplicate.xml @@ -0,0 +1,12 @@ + + + + + + + +