diff --git a/web_widget_open_tab/README.rst b/web_widget_open_tab/README.rst
index 6945c06a0..4d65c054f 100644
--- a/web_widget_open_tab/README.rst
+++ b/web_widget_open_tab/README.rst
@@ -14,13 +14,13 @@ Widget Open on new Tab
: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/15.0/web_widget_open_tab
+ :target: https://github.com/OCA/web/tree/16.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-15-0/web-15-0-web_widget_open_tab
+ :target: https://translation.odoo-community.org/projects/web-16-0/web-16-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/15.0
+ :target: https://runbot.odoo-community.org/runbot/162/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -51,7 +51,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -68,6 +68,7 @@ Contributors
* Enric Tobella
* Raf Ven
+* Dhara Solanki
Maintainers
~~~~~~~~~~~
@@ -82,6 +83,6 @@ 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.
+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/__manifest__.py b/web_widget_open_tab/__manifest__.py
index 3bfe26235..8ad5863f6 100644
--- a/web_widget_open_tab/__manifest__.py
+++ b/web_widget_open_tab/__manifest__.py
@@ -12,6 +12,9 @@
"depends": ["web"],
"demo": ["demo/res_users_view.xml"],
"assets": {
- "web.assets_backend": ["web_widget_open_tab/static/src/js/widget.js"],
+ "web.assets_backend": [
+ "web_widget_open_tab/static/src/xml/open_tab_widget.xml",
+ "web_widget_open_tab/static/src/js/open_tab_widget.esm.js",
+ ],
},
}
diff --git a/web_widget_open_tab/i18n/web_widget_open_tab.pot b/web_widget_open_tab/i18n/web_widget_open_tab.pot
index 631f51b2a..a470253e8 100644
--- a/web_widget_open_tab/i18n/web_widget_open_tab.pot
+++ b/web_widget_open_tab/i18n/web_widget_open_tab.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 15.0\n"
+"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -14,15 +14,15 @@ msgstr ""
"Plural-Forms: \n"
#. module: web_widget_open_tab
-#. openerp-web
-#: code:addons/web_widget_open_tab/static/src/js/widget.js:0
+#. odoo-javascript
+#: code:addons/web_widget_open_tab/static/src/js/open_tab_widget.esm.js:0
#, python-format
-msgid "Click in order to open on new tab"
+msgid "Click to open on new tab"
msgstr ""
#. module: web_widget_open_tab
-#. openerp-web
-#: code:addons/web_widget_open_tab/static/src/js/widget.js:0
+#. odoo-javascript
+#: code:addons/web_widget_open_tab/static/src/js/open_tab_widget.esm.js:0
#, python-format
-msgid "Widget"
+msgid "Open Tab"
msgstr ""
diff --git a/web_widget_open_tab/readme/CONTRIBUTORS.rst b/web_widget_open_tab/readme/CONTRIBUTORS.rst
index 271468bb5..fa8a6cdea 100644
--- a/web_widget_open_tab/readme/CONTRIBUTORS.rst
+++ b/web_widget_open_tab/readme/CONTRIBUTORS.rst
@@ -1,2 +1,3 @@
* Enric Tobella
* Raf Ven
+* Dhara Solanki
diff --git a/web_widget_open_tab/static/description/index.html b/web_widget_open_tab/static/description/index.html
index 81c051d4e..1976cd8d7 100644
--- a/web_widget_open_tab/static/description/index.html
+++ b/web_widget_open_tab/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This addon introduces a new widget.
When added to a field in a tree view, the field appears as a button which opens the record in a new tab.
When clicking on the line (but not on the button), the record is opened in the same window (as in native Odoo).
@@ -398,7 +398,7 @@ On a usual click the record will be opened without changes (keeping the breadcru
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -414,6 +414,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -423,7 +424,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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.
+
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/open_tab_widget.esm.js b/web_widget_open_tab/static/src/js/open_tab_widget.esm.js
new file mode 100644
index 000000000..1bb997362
--- /dev/null
+++ b/web_widget_open_tab/static/src/js/open_tab_widget.esm.js
@@ -0,0 +1,45 @@
+/** @odoo-module */
+
+import {registry} from "@web/core/registry";
+import {standardFieldProps} from "@web/views/fields/standard_field_props";
+import {_lt} from "@web/core/l10n/translation";
+import {Component} from "@odoo/owl";
+
+export class OpenTabWidget extends Component {
+ openNewTab(ev) {
+ ev.stopPropagation();
+ }
+ _getReference() {
+ var url = window.location.href;
+ var searchParams = new URLSearchParams(url.split("#")[1]);
+ searchParams.set("view_type", "form");
+ searchParams.set("id", this.props.value);
+ if (
+ !searchParams.has("model") ||
+ searchParams.get("model") !== this.props.record.resModel
+ ) {
+ searchParams.set("model", this.props.record.resModel);
+ searchParams.delete("action");
+ }
+ return url.split("#")[0] + "#" + searchParams.toString();
+ }
+ loadAttrs(ev) {
+ $(ev.target).tooltip();
+ }
+}
+
+OpenTabWidget.template = "web_widget_open_tab.openTab";
+OpenTabWidget.props = {
+ ...standardFieldProps,
+ title: {type: String, optional: true},
+};
+
+OpenTabWidget.displayName = _lt("Open Tab");
+OpenTabWidget.supportedTypes = ["integer"];
+OpenTabWidget.extractProps = () => {
+ return {
+ title: _lt("Click to open on new tab"),
+ };
+};
+
+registry.category("fields").add("open_tab", OpenTabWidget);
diff --git a/web_widget_open_tab/static/src/js/widget.js b/web_widget_open_tab/static/src/js/widget.js
deleted file mode 100644
index 822def867..000000000
--- a/web_widget_open_tab/static/src/js/widget.js
+++ /dev/null
@@ -1,83 +0,0 @@
-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: "",
- // We want to maintain it black in order to show nothing on the header
- supportedFieldTypes: ["integer"],
- events: _.extend({}, AbstractField.prototype.events, {
- click: "_onClick",
- }),
- isSet: function () {
- return true;
- },
- _getReference: function () {
- var url = window.location.href;
- var searchParams = new URLSearchParams(url.split("#")[1]);
- searchParams.set("view_type", "form");
- searchParams.set("id", this.res_id);
- if (
- !searchParams.has("model") ||
- searchParams.get("model") !== this.model
- ) {
- searchParams.set("model", this.model);
- searchParams.delete("action");
- }
- return url.split("#")[0] + "#" + searchParams.toString();
- },
- _renderReadonly: function () {
- var $content = $("", {
- href: this._getReference(),
- class: "open_tab_widget fa fa-external-link",
- });
- 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/xml/open_tab_widget.xml b/web_widget_open_tab/static/src/xml/open_tab_widget.xml
new file mode 100644
index 000000000..b4e419784
--- /dev/null
+++ b/web_widget_open_tab/static/src/xml/open_tab_widget.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+