mirror of https://github.com/OCA/web.git
[17.0][MIG] web_tree_many2one_clickable
parent
12bd36f07f
commit
2ce565e9ab
|
@ -88,6 +88,7 @@ Contributors
|
||||||
- Anand Kansagra <kansagraanand@hotmail.com>
|
- Anand Kansagra <kansagraanand@hotmail.com>
|
||||||
- Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
- Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
||||||
- Dennis Sluijk <d.sluijk@onestein.nl>
|
- Dennis Sluijk <d.sluijk@onestein.nl>
|
||||||
|
- Maciej Wichowski <maciej@versada.eu>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
{
|
{
|
||||||
"name": "Clickable many2one fields for tree views",
|
"name": "Clickable many2one fields for tree views",
|
||||||
"summary": "Open the linked resource when clicking on their name",
|
"summary": "Open the linked resource when clicking on their name",
|
||||||
"version": "16.0.1.0.0",
|
"version": "17.0.1.0.0",
|
||||||
"category": "Hidden",
|
"category": "Hidden",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"author": "Therp BV, "
|
"author": "Therp BV, "
|
||||||
|
|
|
@ -6,3 +6,4 @@
|
||||||
- Anand Kansagra \<<kansagraanand@hotmail.com>\>
|
- Anand Kansagra \<<kansagraanand@hotmail.com>\>
|
||||||
- Alexandre Díaz \<<alexandre.diaz@tecnativa.com>\>
|
- Alexandre Díaz \<<alexandre.diaz@tecnativa.com>\>
|
||||||
- Dennis Sluijk \<<d.sluijk@onestein.nl>\>
|
- Dennis Sluijk \<<d.sluijk@onestein.nl>\>
|
||||||
|
- Maciej Wichowski \<<maciej@versada.eu>\>
|
||||||
|
|
|
@ -430,6 +430,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<li>Anand Kansagra <<a class="reference external" href="mailto:kansagraanand@hotmail.com">kansagraanand@hotmail.com</a>></li>
|
<li>Anand Kansagra <<a class="reference external" href="mailto:kansagraanand@hotmail.com">kansagraanand@hotmail.com</a>></li>
|
||||||
<li>Alexandre Díaz <<a class="reference external" href="mailto:alexandre.diaz@tecnativa.com">alexandre.diaz@tecnativa.com</a>></li>
|
<li>Alexandre Díaz <<a class="reference external" href="mailto:alexandre.diaz@tecnativa.com">alexandre.diaz@tecnativa.com</a>></li>
|
||||||
<li>Dennis Sluijk <<a class="reference external" href="mailto:d.sluijk@onestein.nl">d.sluijk@onestein.nl</a>></li>
|
<li>Dennis Sluijk <<a class="reference external" href="mailto:d.sluijk@onestein.nl">d.sluijk@onestein.nl</a>></li>
|
||||||
|
<li>Maciej Wichowski <<a class="reference external" href="mailto:maciej@versada.eu">maciej@versada.eu</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
|
|
|
@ -5,29 +5,29 @@
|
||||||
* Copyright 2017 Sodexis <dev@sodexis.com>
|
* Copyright 2017 Sodexis <dev@sodexis.com>
|
||||||
* Copyright 2018 Camptocamp SA
|
* Copyright 2018 Camptocamp SA
|
||||||
* Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
* Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
||||||
|
* Copyright 2024 Versada (https://versada.eu)
|
||||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
|
import {patch} from "@web/core/utils/patch";
|
||||||
import {ListRenderer} from "@web/views/list/list_renderer";
|
import {ListRenderer} from "@web/views/list/list_renderer";
|
||||||
import {Component} from "@odoo/owl";
|
|
||||||
import {useService} from "@web/core/utils/hooks";
|
import {useService} from "@web/core/utils/hooks";
|
||||||
|
|
||||||
export class TreeMany2oneClickableButton extends Component {
|
patch(ListRenderer.prototype, {
|
||||||
setup() {
|
setup() {
|
||||||
this.actionService = useService("action");
|
this.actionService = useService("action");
|
||||||
}
|
super.setup(...arguments);
|
||||||
|
},
|
||||||
async onClick(ev) {
|
async onClickM2oButton(record, column, ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
const field = record.fields[column.name];
|
||||||
|
const value = record.data[column.name];
|
||||||
return this.actionService.doAction({
|
return this.actionService.doAction({
|
||||||
type: "ir.actions.act_window",
|
type: "ir.actions.act_window",
|
||||||
res_model: this.props.field.relation,
|
res_model: field.relation,
|
||||||
res_id: this.props.value[0],
|
res_id: value[0],
|
||||||
views: [[false, "form"]],
|
views: [[false, "form"]],
|
||||||
target: "target",
|
target: "target",
|
||||||
additionalContext: this.props.context || {},
|
additionalContext: column.context || {},
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
});
|
||||||
TreeMany2oneClickableButton.template = "web_tree_many2one_clickable.Button";
|
|
||||||
|
|
||||||
Object.assign(ListRenderer.components, {TreeMany2oneClickableButton});
|
|
||||||
|
|
|
@ -1,21 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<templates>
|
<templates>
|
||||||
<t t-name="web_tree_many2one_clickable.Button" owl="1">
|
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension">
|
||||||
|
<xpath expr="//t[@t-if='!isInvisible']" position="inside">
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-secondary fa fa-arrow-right web_tree_many2one_clickable"
|
class="btn btn-sm btn-secondary fa fa-arrow-right web_tree_many2one_clickable"
|
||||||
t-on-click="onClick"
|
t-on-click="(ev) => this.onClickM2oButton(record, column, ev)"
|
||||||
|
t-if="record.fields[column.name].type == 'many2one' and record.data[column.name] and canUseFormatter(column, record) and !column.options.no_open"
|
||||||
>
|
>
|
||||||
</button>
|
</button>
|
||||||
</t>
|
|
||||||
|
|
||||||
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension">
|
|
||||||
<xpath expr="//Field" position="after">
|
|
||||||
<TreeMany2oneClickableButton
|
|
||||||
record="record"
|
|
||||||
field="record.fields[column.name]"
|
|
||||||
value="record.data[column.name]"
|
|
||||||
t-if="record.fields[column.name].type == 'many2one' and record.data[column.name] and canUseFormatter(column, record) and !props.archInfo.fieldNodes[column.name].options.no_open"
|
|
||||||
/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
Loading…
Reference in New Issue