[MIG] web_tree_many2one_clickable: Migration to 16.0

[MIG] web_tree_many2one_clickable: Migration to 16.0

[MIG] web_tree_many2one_clickable: Migration to 16.0

[MIG] web_tree_many2one_clickable: Migration to 16.0
This commit is contained in:
tarteo
2023-03-01 15:55:42 +01:00
committed by maciej-wichowski
parent 564aa5179c
commit b878a1a6d5
11 changed files with 118 additions and 133 deletions

View File

@@ -0,0 +1,33 @@
/** @odoo-module */
/* Copyright 2013 Therp BV (<http://therp.nl>).
* Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Copyright 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Copyright 2017 Sodexis <dev@sodexis.com>
* Copyright 2018 Camptocamp SA
* Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {ListRenderer} from "@web/views/list/list_renderer";
import {Component} from "@odoo/owl";
import {useService} from "@web/core/utils/hooks";
export class TreeMany2oneClickableButton extends Component {
setup() {
this.actionService = useService("action");
}
async onClick(ev) {
ev.stopPropagation();
return this.actionService.doAction({
type: "ir.actions.act_window",
res_model: this.props.field.relation,
res_id: this.props.value[0],
views: [[false, "form"]],
target: "target",
additionalContext: this.props.context || {},
});
}
}
TreeMany2oneClickableButton.template = "web_tree_many2one_clickable.Button";
Object.assign(ListRenderer.components, {TreeMany2oneClickableButton});

View File

@@ -0,0 +1,10 @@
td.o_list_many2one {
button.web_tree_many2one_clickable {
margin-left: 0.5em;
visibility: hidden;
}
&:hover button.web_tree_many2one_clickable {
visibility: visible;
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="web_tree_many2one_clickable.Button" owl="1">
<button
class="btn btn-sm btn-secondary fa fa-arrow-right web_tree_many2one_clickable"
t-on-click="onClick"
>
</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>
</t>
</templates>