diff --git a/web_duplicate_visibility/README.rst b/web_duplicate_visibility/README.rst new file mode 100644 index 00000000..4058b802 --- /dev/null +++ b/web_duplicate_visibility/README.rst @@ -0,0 +1,82 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================== +Web Duplicate Visibility +======================== + +This module allows to manage the visibility of duplicate button from the form +view declaration. + +Usage +===== + +While the default behavior of odoo is to display the duplicate button when user +is allowed to create a new object. You are now able to remove duplicate button +explicitly even if you are able to create new object:: + + + view name + my.model + + +
+ ... +
+
+
+ +or by extending an existing view:: + + + + 0 + + + +Note that admin user has always access to Duplicate + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/repo/github-com-oca-web-162 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Pierre Verkest +* Christophe Combelles +* Simon André +* Denis Roussel + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_duplicate_visibility/__init__.py b/web_duplicate_visibility/__init__.py new file mode 100644 index 00000000..1a5e9b22 --- /dev/null +++ b/web_duplicate_visibility/__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_duplicate_visibility/__openerp__.py b/web_duplicate_visibility/__openerp__.py new file mode 100644 index 00000000..2d509ff2 --- /dev/null +++ b/web_duplicate_visibility/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Acsone SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Web Duplicate Visibility', + 'summary': """ + This module allows to manage the visibility of duplicate button from + the form view declaration.""", + 'version': '7.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Acsone SA,Odoo Community Association (OCA)', + 'website': 'https://acsone.eu', + 'application': False, + 'installable': True, + 'depends': ['web'], + 'js': ['static/src/js/web_duplicate_visibility.js'], + 'data': [ + ], + 'demo': [ + ], +} diff --git a/web_duplicate_visibility/static/description/icon.svg b/web_duplicate_visibility/static/description/icon.svg new file mode 100644 index 00000000..a7a26d09 --- /dev/null +++ b/web_duplicate_visibility/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/web_duplicate_visibility/static/src/js/web_duplicate_visibility.js b/web_duplicate_visibility/static/src/js/web_duplicate_visibility.js new file mode 100644 index 00000000..ac20d037 --- /dev/null +++ b/web_duplicate_visibility/static/src/js/web_duplicate_visibility.js @@ -0,0 +1,43 @@ + +/* Web Remove Duplicate + @author: Denis Roussel + Inspired by the module web_eradicate_duplicate of Alexis Delattre + and web_duplicate_visibility v9 of Pierre Verkest +*/ + +openerp.web_duplicate_visibility = 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 'duplicate':0 + if ( + this.sidebar && + this.sidebar.items && + this.sidebar.items.other && + this.session.uid != 1 && + (this.fields_view.arch.attrs.duplicate && this.fields_view.arch.attrs.duplicate == '0')) { + 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 + + + + 0 + + + +*/ \ No newline at end of file