From 7df0e7ee77c3c27657e0c0d32c1ac8671ca8f771 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Tue, 5 Jul 2016 17:01:14 +0200 Subject: [PATCH 1/4] [ADD] Add new module to allow the removal of the Duplicate button on every form --- web_remove_duplicate/__init__.py | 20 ++++++ web_remove_duplicate/__openerp__.py | 61 +++++++++++++++++++ .../static/src/js/web_remove_duplicate.js | 41 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 web_remove_duplicate/__init__.py create mode 100644 web_remove_duplicate/__openerp__.py create mode 100644 web_remove_duplicate/static/src/js/web_remove_duplicate.js 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 From 7f17576bdacfc0521c174eb1b0a553f9672a5931 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Wed, 6 Jul 2016 10:26:36 +0200 Subject: [PATCH 2/4] [ADD] Add module to manage Duplicate button visibility (backport v9 module) --- web_duplicate_visibility/README.rst | 82 +++++++++++++++++++ web_duplicate_visibility/__init__.py | 20 +++++ web_duplicate_visibility/__openerp__.py | 22 +++++ .../static/description/icon.svg | 79 ++++++++++++++++++ .../static/src/js/web_duplicate_visibility.js | 43 ++++++++++ 5 files changed, 246 insertions(+) create mode 100644 web_duplicate_visibility/README.rst create mode 100644 web_duplicate_visibility/__init__.py create mode 100644 web_duplicate_visibility/__openerp__.py create mode 100644 web_duplicate_visibility/static/description/icon.svg create mode 100644 web_duplicate_visibility/static/src/js/web_duplicate_visibility.js 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 From e4882b7e608e6d0970350ff65ed9c0ea7a716f58 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Wed, 6 Jul 2016 10:31:00 +0200 Subject: [PATCH 3/4] [REM] Remove former created module --- web_remove_duplicate/__init__.py | 20 ------ web_remove_duplicate/__openerp__.py | 61 ------------------- .../static/src/js/web_remove_duplicate.js | 41 ------------- 3 files changed, 122 deletions(-) delete mode 100644 web_remove_duplicate/__init__.py delete mode 100644 web_remove_duplicate/__openerp__.py delete mode 100644 web_remove_duplicate/static/src/js/web_remove_duplicate.js diff --git a/web_remove_duplicate/__init__.py b/web_remove_duplicate/__init__.py deleted file mode 100644 index 1a5e9b22..00000000 --- a/web_remove_duplicate/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- 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 deleted file mode 100644 index 088dff54..00000000 --- a/web_remove_duplicate/__openerp__.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- 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 deleted file mode 100644 index 1f281adb..00000000 --- a/web_remove_duplicate/static/src/js/web_remove_duplicate.js +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 From f8c6fadc8609634e154bd8b2f7e9c6bc79aa4f3d Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Wed, 6 Jul 2016 12:01:47 +0200 Subject: [PATCH 4/4] [FIX] Add a description to manifest --- web_duplicate_visibility/__openerp__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web_duplicate_visibility/__openerp__.py b/web_duplicate_visibility/__openerp__.py index 2d509ff2..72feec07 100644 --- a/web_duplicate_visibility/__openerp__.py +++ b/web_duplicate_visibility/__openerp__.py @@ -13,6 +13,16 @@ 'website': 'https://acsone.eu', 'application': False, 'installable': True, + "description": """ +Web Duplicate Visibility +======================== +Features: +--------- + +Allows to add a 'duplicate' attribute to a form and to set it at '0' +to remove the duplicate function + + """, 'depends': ['web'], 'js': ['static/src/js/web_duplicate_visibility.js'], 'data': [