diff --git a/web_widget_open_tab/README.rst b/web_widget_open_tab/README.rst new file mode 100644 index 000000000..58b30701d --- /dev/null +++ b/web_widget_open_tab/README.rst @@ -0,0 +1,84 @@ +====================== +Widget Open on new Tab +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| 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 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/11.0/web_widget_open_tab + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_widget_open_tab + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon creates a new widget that can be used to open on a new tab a record from a tree. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Edit the tree view and add the widget as the first field, usually, we should use: +.. code-block:: xml + + + +Now, we can open when clicking with the mouse wheel over the eye. +On a usual click the record will be opened without changes (keeping the breadcrumbs). + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_open_tab/__init__.py b/web_widget_open_tab/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_widget_open_tab/__manifest__.py b/web_widget_open_tab/__manifest__.py new file mode 100644 index 000000000..d79765a68 --- /dev/null +++ b/web_widget_open_tab/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Widget Open on new Tab', + 'summary': """ + Allow to open record from trees on new tab from tree views""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Creu Blanca,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/web', + 'depends': [ + 'web' + ], + 'data': [ + 'views/assets.xml', + ], +} diff --git a/web_widget_open_tab/readme/CONTRIBUTORS.rst b/web_widget_open_tab/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..93ec993e0 --- /dev/null +++ b/web_widget_open_tab/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/web_widget_open_tab/readme/DESCRIPTION.rst b/web_widget_open_tab/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1bfe54f9d --- /dev/null +++ b/web_widget_open_tab/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This addon creates a new widget that can be used to open on a new tab a record from a tree. diff --git a/web_widget_open_tab/readme/USAGE.rst b/web_widget_open_tab/readme/USAGE.rst new file mode 100644 index 000000000..bd13b6079 --- /dev/null +++ b/web_widget_open_tab/readme/USAGE.rst @@ -0,0 +1,7 @@ +Edit the tree view and add the widget as the first field, usually, we should use: +.. code-block:: xml + + + +Now, we can open when clicking with the mouse wheel over the eye. +On a usual click the record will be opened without changes (keeping the breadcrumbs). diff --git a/web_widget_open_tab/static/description/icon.png b/web_widget_open_tab/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_open_tab/static/description/icon.png differ diff --git a/web_widget_open_tab/static/description/index.html b/web_widget_open_tab/static/description/index.html new file mode 100644 index 000000000..71541c1d1 --- /dev/null +++ b/web_widget_open_tab/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Widget Open on new Tab + + + +
+

Widget Open on new Tab

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

This addon creates a new widget that can be used to open on a new tab a record from a tree.

+

Table of contents

+ +
+

Usage

+

Edit the tree view and add the widget as the first field, usually, we should use: +.. code-block:: xml

+
+<field name=”id” widget=”open_tab”/>
+

Now, we can open when clicking with the mouse wheel over the eye. +On a usual click the record will be opened without changes (keeping the breadcrumbs).

+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_widget_open_tab/static/src/js/widget.js b/web_widget_open_tab/static/src/js/widget.js new file mode 100644 index 000000000..4941d8fe9 --- /dev/null +++ b/web_widget_open_tab/static/src/js/widget.js @@ -0,0 +1,72 @@ +odoo.define('web_widget_open_tab.FieldOpenTab', function(require) { + "use strict"; + + var AbstractField = require('web.AbstractField'); + var field_registry = require('web.field_registry'); + var ListRenderer = require('web.ListRenderer'); + var core = require('web.core'); + var config = require('web.config'); + var qweb = core.qweb; + var _t = core._t; + + var FieldOpenTab = AbstractField.extend({ + description: "", + supportedFieldTypes: ['integer'], + events: _.extend({}, AbstractField.prototype.events, { + 'click': '_onClick', + }), + isSet: function () { + return true; + }, + _getReference: function () { + var url = new URL(window.location.href); + return url.hash.replace(/view_type=\w+/i, "view_type=form") + '&id=' + this.res_id; + }, + _renderReadonly: function () { + var $content = $( + '' + ).addClass('open_tab_widget fa fa-eye'); + var self = this; + $content.tooltip({ + delay: { show: 1000, hide: 0 }, + title: function () { + return qweb.render('WidgetButton.tooltip', { + debug: config.debug, + state: self.record, + node: { + attrs: { + 'help': _t('Click in order to open on new tab'), + 'type': _t('Widget') + } + }, + }); + }, + }); + this.$el.append($content) + }, + _onClick: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + var element = $(ev.currentTarget).find('a'); + if (element != null && element[0].href != null) { + window.open(this._getReference()); + } + }, + }); + ListRenderer.include({ + // We want to simplify the header of this kind of elements + // and disallow sorting + _renderHeaderCell: function (node) { + var $th = this._super.apply(this, arguments); + if (node.attrs.widget === 'open_tab') { + $th.removeClass('o_column_sortable'); + $th[0].width = 1; + } + return $th; + }, + }); + + field_registry.add('open_tab', FieldOpenTab); + return FieldOpenTab; + +}); diff --git a/web_widget_open_tab/static/src/less/open_tab.less b/web_widget_open_tab/static/src/less/open_tab.less new file mode 100644 index 000000000..b4bb6fd11 --- /dev/null +++ b/web_widget_open_tab/static/src/less/open_tab.less @@ -0,0 +1,10 @@ +.open_tab_widget { + .child { + visibility: hidden; + } + &:hover { + .child { + visibility: visible; + } + } +} diff --git a/web_widget_open_tab/views/assets.xml b/web_widget_open_tab/views/assets.xml new file mode 100644 index 000000000..31ea81804 --- /dev/null +++ b/web_widget_open_tab/views/assets.xml @@ -0,0 +1,11 @@ + + + +