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

View File

@@ -0,0 +1,77 @@
import {ListController} from "@web/views/list/list_controller";
import {patch} from "@web/core/utils/patch";
function flatten(arr) {
return arr.reduce((flat, toFlatten) => {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
patch(ListController.prototype, {
async expandAllGroups() {
// We expand layer by layer. So first we need to find the highest
// layer that's not already fully expanded.
let layer = this.model.root.groups;
let max_length = 0;
while (layer.length) {
max_length = Math.max(max_length, layer.length);
const closed = layer.filter(function (group) {
return group._config.isFolded;
});
if (closed.length) {
// This layer is not completely expanded, expand it
await layer.forEach((group) => {
group._config.isFolded = false;
});
break;
}
// This layer is completely expanded, move to the next
layer = flatten(
layer.map(function (group) {
return group.list.groups || [];
})
);
}
// Save the default value of MAX_NUMBER_OPENED_GROUPS to restore it later
const default_max_opened = this.model.constructor.MAX_NUMBER_OPENED_GROUPS;
// Set in MAX_NUMBER_OPENED_GROUPS the maximum number of groups that can be opened
this.model.constructor.MAX_NUMBER_OPENED_GROUPS = max_length;
await this.model.root.load();
// Restore the default value of MAX_NUMBER_OPENED_GROUPS
this.model.constructor.MAX_NUMBER_OPENED_GROUPS = default_max_opened;
this.model.notify();
},
async collapseAllGroups() {
// We collapse layer by layer. So first we need to find the deepest
// layer that's not already fully collapsed.
let layer = this.model.root.groups;
let max_length = 0;
while (layer.length) {
max_length = Math.max(max_length, layer.length);
const next = flatten(
layer.map(function (group) {
return group.list.groups || [];
})
).filter(function (group) {
return !group._config.isFolded;
});
if (!next.length) {
// Next layer is fully collapsed, so collapse this one
await layer.forEach((group) => {
group._config.isFolded = true;
});
break;
}
layer = next;
}
// Save the default value of MAX_NUMBER_OPENED_GROUPS to restore it later
const default_max_opened = this.model.constructor.MAX_NUMBER_OPENED_GROUPS;
// Set in MAX_NUMBER_OPENED_GROUPS the maximum number of groups that can be opened
this.model.constructor.MAX_NUMBER_OPENED_GROUPS = max_length;
await this.model.root.load();
// Restore the default value of MAX_NUMBER_OPENED_GROUPS
this.model.constructor.MAX_NUMBER_OPENED_GROUPS = default_max_opened;
this.model.notify();
},
});

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.ListView.Buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside">
<t t-if="model.root.isGrouped">
<button
type="button"
class="btn btn-secondary fa fa-expand oe_group_by_expand"
data-tooltip="Expand"
aria-label="Expand"
t-on-click="expandAllGroups"
/>
<button
type="button"
class="btn btn-secondary fa fa-compress oe_group_by_collapse"
data-tooltip="Compress"
aria-label="Compress"
t-on-click="collapseAllGroups"
/>
</t>
</xpath>
</t>
</templates>