mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-23 17:42:02 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -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,
|
||||
}),
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue