[IMP] web_refresher: Provide the ability to reload information from a report view

This commit is contained in:
Carlos Roca
2024-02-09 11:49:48 +01:00
parent 10a600b495
commit c044cabaf3
7 changed files with 78 additions and 4 deletions

View File

@@ -0,0 +1,9 @@
/** @odoo-module **/
/* Copyright 2024 Tecnativa - Carlos Roca
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
import {ControlPanel} from "@web/search/control_panel/control_panel";
import {Refresher} from "./refresher.esm";
ControlPanel.components = Object.assign({}, ControlPanel.components, {
Refresher,
});

View File

@@ -4,12 +4,32 @@
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
const {Component} = owl;
import {useService} from "@web/core/utils/hooks";
export class Refresher extends Component {
_doRefresh() {
setup() {
super.setup();
this.action = useService("action");
}
async _doRefresh() {
const viewAction = this.action.currentController.action;
// Allow refresh reports
if (["ir.actions.report", "ir.actions.client"].includes(viewAction.type)) {
const options = {};
if (this.env.config.breadcrumbs.length > 1) {
const breadcrumb = this.env.config.breadcrumbs.slice(-1);
await this.action.restore(breadcrumb.jsId);
} else {
options.clearBreadcrumbs = true;
}
return this.action.doAction(viewAction, options);
}
// Note: here we use the pager props, see xml
const {limit, offset} = this.props;
this.props.onUpdate({offset, limit});
if (!limit && !offset) {
return;
}
return this.props.onUpdate({offset, limit});
}
}