diff --git a/web_tree_many2one_clickable/README.rst b/web_tree_many2one_clickable/README.rst new file mode 100644 index 00000000..7899e7b0 --- /dev/null +++ b/web_tree_many2one_clickable/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================================== +Clickable many2one fields for tree views +======================================== + +This addon forces Odoo to use many2one widget on a many2one fields in +tree views. This allows users to open linked resources from trees directly, +without accessing the form. + +Configuration +============= + +After installation, all many2one and reference fields will be clickable by default. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/11.0 + + +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 smash it by providing a detailed and welcomed feedback. + + +Credits +======= + +Contributors +------------ + +* Therp BV +* Pedro M. Baeza +* Antonio Espinosa +* Sodexis +* Artem Kostyuk + +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_tree_many2one_clickable/__init__.py b/web_tree_many2one_clickable/__init__.py new file mode 100644 index 00000000..d9d1f13d --- /dev/null +++ b/web_tree_many2one_clickable/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_tree_many2one_clickable/__manifest__.py b/web_tree_many2one_clickable/__manifest__.py new file mode 100644 index 00000000..f4a92f8a --- /dev/null +++ b/web_tree_many2one_clickable/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2013 Therp BV (). +# Copyright 2015 Pedro M. Baeza +# Copyright 2015 Antonio Espinosa +# Copyright 2017 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Clickable many2one fields for tree views", + "summary": "Open the linked resource when clicking on their name", + "version": "11.0.1.0.0", + "category": "Hidden", + "website": "https://github.com/OCA/web", + "author": "Therp BV, " + "Tecnativa, " + "Camptocamp, " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": [ + 'web', + ], + "data": [ + 'static/src/xml/assets.xml', + ], +} diff --git a/web_tree_many2one_clickable/static/description/icon.png b/web_tree_many2one_clickable/static/description/icon.png new file mode 100644 index 00000000..f1006195 Binary files /dev/null and b/web_tree_many2one_clickable/static/description/icon.png differ diff --git a/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js b/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js new file mode 100644 index 00000000..47ef9d56 --- /dev/null +++ b/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js @@ -0,0 +1,21 @@ +/* Copyright 2013 Therp BV (). + * Copyright 2015 Pedro M. Baeza + * Copyright 2016 Antonio Espinosa + * Copyright 2017 Sodexis + * Copyright 2018 Camptocamp SA + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define('web_tree_many2one_clickable.many2one_clickable', function (require) { + var ListRenderer = require('web.ListRenderer'); + + ListRenderer.include({ + _renderBodyCell: function (record, node, colIndex, options) { + if (!node.attrs.widget && this.state.fields[node.attrs.name].type === 'many2one') { + // no explicit widget provided on a many2one field, + // force `many2one` widget + node.attrs.widget = 'many2one'; + } + return this._super(record, node, colIndex, options); + } + }); +}); diff --git a/web_tree_many2one_clickable/static/src/xml/assets.xml b/web_tree_many2one_clickable/static/src/xml/assets.xml new file mode 100644 index 00000000..a926e09f --- /dev/null +++ b/web_tree_many2one_clickable/static/src/xml/assets.xml @@ -0,0 +1,12 @@ + + + + +