Browse Source

Merge pull request #383 from acsone/7.0-web_duplicate_visibility-dro

[7.0] Add web duplicate visibility module
pull/112/merge
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
0ff135bc26
  1. 82
      web_duplicate_visibility/README.rst
  2. 20
      web_duplicate_visibility/__init__.py
  3. 32
      web_duplicate_visibility/__openerp__.py
  4. 79
      web_duplicate_visibility/static/description/icon.svg
  5. 43
      web_duplicate_visibility/static/src/js/web_duplicate_visibility.js

82
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::
<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.

20
web_duplicate_visibility/__init__.py

@ -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/>.
#
##############################################################################

32
web_duplicate_visibility/__openerp__.py

@ -0,0 +1,32 @@
# -*- 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,
"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': [
],
'demo': [
],
}

79
web_duplicate_visibility/static/description/icon.svg
File diff suppressed because it is too large
View File

43
web_duplicate_visibility/static/src/js/web_duplicate_visibility.js

@ -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…
Cancel
Save