forked from Techsystech/web
[MIG] web_widget_open_tab: Migration to 17.0
parent
5c423c80e9
commit
5ab1cf6550
|
@ -5,7 +5,7 @@
|
|||
"name": "Widget Open on new Tab",
|
||||
"summary": """
|
||||
Allow to open record from trees on new tab from tree views""",
|
||||
"version": "16.0.2.0.0",
|
||||
"version": "17.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import {Component} from "@odoo/owl";
|
||||
import {_t} from "@web/core/l10n/translation";
|
||||
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) {
|
||||
|
@ -13,7 +13,7 @@ export class OpenTabWidget extends Component {
|
|||
var url = window.location.href;
|
||||
var searchParams = new URLSearchParams(url.split("#")[1]);
|
||||
searchParams.set("view_type", "form");
|
||||
searchParams.set("id", this.props.value);
|
||||
searchParams.set("id", this.props.record.data.id);
|
||||
if (
|
||||
!searchParams.has("model") ||
|
||||
searchParams.get("model") !== this.props.record.resModel
|
||||
|
@ -34,12 +34,13 @@ OpenTabWidget.props = {
|
|||
title: {type: String, optional: true},
|
||||
};
|
||||
|
||||
OpenTabWidget.displayName = _lt("Open Tab");
|
||||
OpenTabWidget.supportedTypes = ["integer"];
|
||||
OpenTabWidget.extractProps = () => {
|
||||
return {
|
||||
title: _lt("Click to open on new tab"),
|
||||
};
|
||||
export const openTabWidget = {
|
||||
component: OpenTabWidget,
|
||||
displayName: _t("Open Tab"),
|
||||
supportedTypes: ["integer"],
|
||||
extractProps: () => ({
|
||||
title: _t("Click to open on new tab"),
|
||||
}),
|
||||
};
|
||||
|
||||
registry.category("fields").add("open_tab", OpenTabWidget);
|
||||
registry.category("fields").add("open_tab", openTabWidget);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template>
|
||||
<t t-name="web_widget_open_tab.openTab" owl="1">
|
||||
<t t-name="web_widget_open_tab.openTab">
|
||||
<a
|
||||
class="btn open_tab_widget fa fa-external-link"
|
||||
t-att-href="_getReference()"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from . import test_main
|
|
@ -0,0 +1,21 @@
|
|||
from odoo.tests import common
|
||||
|
||||
|
||||
class Test(common.TransactionCase):
|
||||
def test_add_open_tab_field(self):
|
||||
self.env["ir.model"]._get("res.company").add_open_tab_field = True
|
||||
arch, view = self.env["res.company"]._get_view(view_id=None, view_type="tree")
|
||||
found = arch.xpath("//field[@widget='open_tab']")
|
||||
self.assertEqual(len(found), 1)
|
||||
|
||||
def test_no_add_open_tab_field(self):
|
||||
self.env["ir.model"]._get("res.company").add_open_tab_field = False
|
||||
arch, view = self.env["res.company"]._get_view(view_id=None, view_type="tree")
|
||||
found = arch.xpath("//field[@widget='open_tab']")
|
||||
self.assertFalse(found)
|
||||
|
||||
def test_add_open_tab_field_no_name_field(self):
|
||||
self.env["ir.model"]._get("res.groups").add_open_tab_field = True
|
||||
arch, view = self.env["res.groups"]._get_view(view_id=None, view_type="tree")
|
||||
found = arch.xpath("//field[@widget='open_tab']")
|
||||
self.assertEqual(len(found), 1)
|
Loading…
Reference in New Issue