diff --git a/web_remove_duplicate/__init__.py b/web_remove_duplicate/__init__.py new file mode 100644 index 00000000..1a5e9b22 --- /dev/null +++ b/web_remove_duplicate/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2016 Acsone SA (). +# +# 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 . +# +############################################################################## diff --git a/web_remove_duplicate/__openerp__.py b/web_remove_duplicate/__openerp__.py new file mode 100644 index 00000000..088dff54 --- /dev/null +++ b/web_remove_duplicate/__openerp__.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2016 Acsone SA (). +# +# 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": "Remove Duplicate Action", + "version": "1.0", + "author": "Acsone SA,Odoo Community Association (OCA)", + "license": "AGPL-3", + "complexity": "normal", + "description": """ +Introduction +============ + +This addon provide a form option to allow to hide 'Duplicate' action +on objects + +Usage +===== + +Simply depend on web_remove_duplicate and add the attribute 'remove_dependency' + on the form view + """, + "category": "Dependency", + "depends": [ + 'web', + ], + "data": [ + ], + "js": [ + 'static/src/js/web_remove_duplicate.js' + ], + "css": [ + ], + "qweb": [ + ], + "test": [ + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies": { + 'python': [], + }, +} diff --git a/web_remove_duplicate/static/src/js/web_remove_duplicate.js b/web_remove_duplicate/static/src/js/web_remove_duplicate.js new file mode 100644 index 00000000..1f281adb --- /dev/null +++ b/web_remove_duplicate/static/src/js/web_remove_duplicate.js @@ -0,0 +1,41 @@ +/* Web Remove Duplicate + @author: Denis Roussel + Inspired by the module web_eradicate_duplicate of Alexis Delattre +*/ + +openerp.web_remove_duplicate = function (instance) { + var _t = instance.web._t; + + instance.web.FormView.include({ + load_form: function(data) { + this._super(data); + // Remove More > Duplicate button except admin + // if the form has the attribute 'remove_duplicate' + if ( + this.sidebar && + this.sidebar.items && + this.sidebar.items.other && + this.session.uid != 1 && + this.fields_view.arch.attrs.remove_duplicate) { + var new_items_other = _.reject(this.sidebar.items.other, function (item) { + return item.label === _t('Duplicate'); + }); + this.sidebar.items.other = new_items_other; + } + } + }); +}; + +/* +EXAMPLE : enable duplicate on account.move : + + remove_duplicate.account_move_form + account.move + + + + True + + + +*/ \ No newline at end of file