mirror of https://github.com/OCA/web.git
[MIG] web_widget_open_tab: Migration to 16.0
parent
46acdc8c2d
commit
27b941d272
|
@ -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 <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 <https://github.com/OCA/web/issues/new?body=module:%20web_widget_open_tab%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_open_tab%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
|
@ -68,6 +68,7 @@ Contributors
|
|||
|
||||
* Enric Tobella <etobella@creublanca.es>
|
||||
* Raf Ven <raf.ven@dynapps.be>
|
||||
* Dhara Solanki <dhara.solanki@initos.com>
|
||||
|
||||
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 <https://github.com/OCA/web/tree/15.0/web_widget_open_tab>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_widget_open_tab>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -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",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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 ""
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
* Enric Tobella <etobella@creublanca.es>
|
||||
* Raf Ven <raf.ven@dynapps.be>
|
||||
* Dhara Solanki <dhara.solanki@initos.com>
|
||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_widget_open_tab"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_widget_open_tab"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_widget_open_tab"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_widget_open_tab"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>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).</p>
|
||||
|
@ -398,7 +398,7 @@ On a usual click the record will be opened without changes (keeping the breadcru
|
|||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_open_tab%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_open_tab%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -414,6 +414,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<ul class="simple">
|
||||
<li>Enric Tobella <<a class="reference external" href="mailto:etobella@creublanca.es">etobella@creublanca.es</a>></li>
|
||||
<li>Raf Ven <<a class="reference external" href="mailto:raf.ven@dynapps.be">raf.ven@dynapps.be</a>></li>
|
||||
<li>Dhara Solanki <<a class="reference external" href="mailto:dhara.solanki@initos.com">dhara.solanki@initos.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
@ -423,7 +424,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_widget_open_tab">OCA/web</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_widget_open_tab">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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);
|
|
@ -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 = $("<a/>", {
|
||||
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;
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template>
|
||||
<t t-name="web_widget_open_tab.openTab" owl="1">
|
||||
<a
|
||||
class="btn open_tab_widget fa fa-external-link"
|
||||
t-att-href="_getReference()"
|
||||
target="_blank"
|
||||
t-on-click="openNewTab"
|
||||
t-att-title="props.title"
|
||||
t-on-mouseenter="ev => this.loadAttrs(ev)"
|
||||
>
|
||||
</a>
|
||||
</t>
|
||||
</template>
|
Loading…
Reference in New Issue