Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
30
web_widget_open_tab/static/src/js/open_tab_widget.esm.js
Executable file
30
web_widget_open_tab/static/src/js/open_tab_widget.esm.js
Executable file
@@ -0,0 +1,30 @@
|
||||
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";
|
||||
|
||||
export class OpenTabWidget extends Component {
|
||||
openNewTab(ev) {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
_getReference() {
|
||||
return `/odoo/${this.props.record.resModel}/${this.props.record.data.id}`;
|
||||
}
|
||||
}
|
||||
|
||||
OpenTabWidget.template = "web_widget_open_tab.openTab";
|
||||
OpenTabWidget.props = {
|
||||
...standardFieldProps,
|
||||
title: {type: String, optional: true},
|
||||
};
|
||||
|
||||
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);
|
||||
12
web_widget_open_tab/static/src/xml/open_tab_widget.xml
Executable file
12
web_widget_open_tab/static/src/xml/open_tab_widget.xml
Executable file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template>
|
||||
<t t-name="web_widget_open_tab.openTab">
|
||||
<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>
|
||||
</template>
|
||||
Reference in New Issue
Block a user