Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@@ -0,0 +1,36 @@
/* Copyright 2019 Tecnativa - David Vidal
* Copyright 2024 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {DomainEditorDialog} from "./widget_domain_editor_dialog.esm";
import {DomainField} from "@web/views/fields/domain/domain_field";
import {_t} from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";
patch(DomainField.prototype, {
onButtonClick(ev) {
const self = this;
ev.preventDefault();
if (this.props.readonly) {
return this._super.apply(this, arguments);
}
if (!this.props.value) {
this.props.value = "[]";
}
this.addDialog(DomainEditorDialog, {
title: _t("Select records..."),
noCreate: true,
multiSelect: true,
resModel: this.getResModel(),
dynamicFilters: [
{
description: _t("Selected domain"),
domain: this.getEvaluatedDomain(),
},
],
context: this.getContext(),
onSelected: function (resIds) {
self.update(this.get_domain(resIds));
},
});
},
});

View File

@@ -0,0 +1,78 @@
/* Copyright 2019 Tecnativa - David Vidal
* Copyright 2024 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {Domain} from "@web/core/domain";
import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog";
import {deepEqual} from "@web/core/utils/objects";
export function findChildren(comp, predicate = (e) => e) {
const queue = [];
[].unshift.apply(queue, Object.values(comp.__owl__.children));
while (queue.length > 0) {
const curNode = queue.pop();
if (predicate(curNode)) {
return curNode;
}
[].unshift.apply(queue, Object.values(curNode.component.__owl__.children));
}
}
export class DomainEditorDialog extends SelectCreateDialog {
/**
* Bind this to allow call get_domain from onSelected function definition.
*
* @override
*/
async select(resIds) {
if (this.props.onSelected) {
const onselected = this.props.onSelected.bind(this);
await onselected(resIds);
this.props.close();
}
}
_getDomainOfGroups(groups, domain) {
const groups_unfolded = groups.filter((g) => !g.isFolded);
const groups_domain = [];
for (const group of groups_unfolded) {
const group_list = group.list;
if (group_list.groupBy.length) {
groups_domain.push(this._getDomainOfGroups(group_list.groups, domain));
} else {
let group_domain = group_list.domain.slice();
domain.forEach((d) => {
group_domain = group_domain.filter((x) => !deepEqual(x, d));
});
group_domain = group_domain.filter((x) => x !== "&");
groups_domain.push(group_domain);
}
}
return Domain.or(groups_domain).toList();
}
get_domain(resIds) {
const dynamicList = findChildren(
this,
(node) =>
node.component &&
node.component.model &&
node.component.model.root &&
["DynamicGroupList", "DynamicRecordList"].includes(
node.component.model.root.constructor.name
)
).component.model.root;
let domain = dynamicList.domain;
let group_domain = [];
const checkbox = document.querySelector(".o_list_record_selector input");
const isChecked = checkbox ? checkbox.checked : false;
if (isChecked) {
if (dynamicList.groupBy.length) {
group_domain = this._getDomainOfGroups(dynamicList.groups, domain);
}
} else {
domain = domain.concat([["id", "in", resIds]]);
}
return JSON.stringify(domain.concat(group_domain));
}
}