forked from Techsystech/web
[ADD] Add module to manage Duplicate button visibility (backport v9 module)
parent
7df0e7ee77
commit
7f17576bda
|
@ -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::
|
||||
|
||||
<record id="view_form_id" model="ir.ui.view">
|
||||
<field name="name">view name</field>
|
||||
<field name="model">my.model</field>
|
||||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="..." duplicate="0">
|
||||
...
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
or by extending an existing view::
|
||||
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form" position="attributes">
|
||||
<attribute name="duplicate">0</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
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
|
||||
<https://github.com/OCA/web/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Pierre Verkest <pverkest@anybox.fr>
|
||||
* Christophe Combelles <ccomb@anybox.fr>
|
||||
* Simon André <sandre@anybox.fr>
|
||||
* Denis Roussel <denis.roussel@acsone.eu>
|
||||
|
||||
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.
|
|
@ -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,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': [
|
||||
],
|
||||
}
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 45 KiB |
|
@ -0,0 +1,43 @@
|
|||
|
||||
/* Web Remove Duplicate
|
||||
@author: Denis Roussel <denis.roussel@acsone.eu>
|
||||
Inspired by the module web_eradicate_duplicate of Alexis Delattre
|
||||
and web_duplicate_visibility v9 of Pierre Verkest <pverkest@anybox.fr>
|
||||
*/
|
||||
|
||||
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 :
|
||||
<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="duplicate">0</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
*/
|
Loading…
Reference in New Issue