19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -0,0 +1,58 @@
import { _t } from "@web/core/l10n/translation";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
class X2ManyButtons extends Component {
static template = "account.X2ManyButtons";
static props = {
...standardFieldProps,
treeLabel: { type: String },
nbRecordsShown: { type: Number, optional: true },
};
setup() {
this.orm = useService("orm");
this.action = useService("action");
}
async openTreeAndDiscard() {
const ids = this.currentField.currentIds;
await this.props.record.discard();
const context = this.currentField.resModel === "account.move"
? { list_view_ref: "account.view_duplicated_moves_tree_js" }
: {};
this.action.doAction({
name: this.props.treeLabel,
type: "ir.actions.act_window",
res_model: this.currentField.resModel,
views: [
[false, "list"],
[false, "form"],
],
domain: [["id", "in", ids]],
context: context,
});
}
async openFormAndDiscard(id) {
const action = await this.orm.call(this.currentField.resModel, "action_open_business_doc", [id], {});
await this.props.record.discard();
this.action.doAction(action);
}
get currentField() {
return this.props.record.data[this.props.name];
}
}
X2ManyButtons.template = "account.X2ManyButtons";
registry.category("fields").add("x2many_buttons", {
component: X2ManyButtons,
relatedFields: [{ name: "display_name", type: "char" }],
extractProps: ({ attrs, string }) => ({
treeLabel: string || _t("Records"),
nbRecordsShown: attrs.nb_records_shown ? parseInt(attrs.nb_records_shown) : 3,
}),
});

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="account.X2ManyButtons">
<div class="d-flex align-items-center">
<t t-foreach="this.currentField.records.slice(0, props.nbRecordsShown)" t-as="record" t-key="record.id">
<button class="btn btn-link p-0"
t-on-click="() => this.openFormAndDiscard(record.resId)"
t-att-data-hotkey="`shift+${record_index + 1}`"
t-out="record.data.display_name"/>
<span t-if="!record_last" class="pe-1">,</span>
</t>
<t t-if="this.currentField.count gt props.nbRecordsShown">
<button class="btn btn-link p-0" t-on-click="() => this.openTreeAndDiscard()" data-hotkey="shift+4">... (View all)</button>
</t>
</div>
</t>
</templates>