mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_refresher: Provide the ability to reload information from a report view
This commit is contained in:
28
web_refresher/static/src/js/client_action_adapter.esm.js
Normal file
28
web_refresher/static/src/js/client_action_adapter.esm.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/** @odoo-module **/
|
||||
/* Copyright 2024 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
import {ClientActionAdapter} from "@web/legacy/action_adapters";
|
||||
import Context from "web.Context";
|
||||
import {mapDoActionOptionAPI} from "@web/legacy/backend_utils";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {wrapSuccessOrFail} from "@web/legacy/utils";
|
||||
|
||||
patch(ClientActionAdapter.prototype, "web_refresher.ClientActionAdapter", {
|
||||
_trigger_up(ev) {
|
||||
const payload = ev.data;
|
||||
if (ev.name === "refresh_report") {
|
||||
this.actionService.restore(payload.controllerID).then(() => {
|
||||
if (payload.action.context) {
|
||||
payload.action.context = new Context(payload.action.context).eval();
|
||||
}
|
||||
const legacyOptions = mapDoActionOptionAPI(payload.options);
|
||||
wrapSuccessOrFail(
|
||||
this.actionService.doAction(payload.action, legacyOptions),
|
||||
payload
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this._super(...arguments);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,15 +1,28 @@
|
||||
/** @odoo-module **/
|
||||
/* Copyright 2022 Tecnativa - Alexandre D. Díaz
|
||||
* Copyright 2022 Tecnativa - Carlos Roca
|
||||
* Copyright 2022-2024 Tecnativa - Carlos Roca
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
||||
const {Component} = owl;
|
||||
|
||||
export class Refresher extends Component {
|
||||
_doRefresh() {
|
||||
// Allow refresh reports
|
||||
if (["ir.actions.report", "ir.actions.client"].includes(this.env.action.type)) {
|
||||
const options = {};
|
||||
const breadcrumbs = this.__owl__.parent.props.breadcrumbs;
|
||||
if (breadcrumbs.length) {
|
||||
return this.trigger("refresh-report", {
|
||||
action: this.env.action,
|
||||
controllerID: breadcrumbs.slice(-1).controllerID,
|
||||
});
|
||||
}
|
||||
options.clear_breadcrumbs = true;
|
||||
return this.trigger("do-action", {action: this.env.action, options});
|
||||
}
|
||||
// Note: here we use the pager props, see xml
|
||||
const {limit, currentMinimum} = this.props;
|
||||
this.trigger("pager-changed", {currentMinimum, limit});
|
||||
return this.trigger("pager-changed", {currentMinimum, limit});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user