Browse Source
[ADD] Add new module to allow the removal of the Duplicate button on every form
pull/382/head
[ADD] Add new module to allow the removal of the Duplicate button on every form
pull/382/head
Denis Roussel
9 years ago
3 changed files with 122 additions and 0 deletions
-
20web_remove_duplicate/__init__.py
-
61web_remove_duplicate/__openerp__.py
-
41web_remove_duplicate/static/src/js/web_remove_duplicate.js
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2016 Acsone SA (<http://acsone.eu>). |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
@ -0,0 +1,61 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2016 Acsone SA (<http://acsone.eu>). |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
{ |
|||
"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': [], |
|||
}, |
|||
} |
@ -0,0 +1,41 @@ |
|||
/* Web Remove Duplicate |
|||
@author: Denis Roussel <denis.roussel@acsone.eu> |
|||
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 : |
|||
<record id="view_move_form" model="ir.ui.view"> |
|||
<field name="name">remove_duplicate.account_move_form</field> |
|||
<field name="model">account.move</field> |
|||
<field name="inherit_id" ref="account.view_move_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="/form" position="attributes"> |
|||
<attribute name="remove_duplicate">True</attribute> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
*/ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue