Skip to content

Commit

Permalink
Merge PR OCA#2740 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 8, 2024
2 parents 4c7b800 + 9941a58 commit 4d3274a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web_refresher/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Web Refresher
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:88fce35323996a71b86623ff97b9a099bd381b6c37a3cb2ca6ba41179c04926d
!! source digest: sha256:f8d8ed8f9762830a5153097507a407ee9523c05093d1b424ae19dc30ccef9486
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
1 change: 1 addition & 0 deletions web_refresher/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"assets": {
"web.assets_backend": [
"web_refresher/static/src/scss/refresher.scss",
"web_refresher/static/src/js/client_action_adapter.esm.js",
"web_refresher/static/src/js/refresher.esm.js",
"web_refresher/static/src/js/control_panel.esm.js",
],
Expand Down
2 changes: 1 addition & 1 deletion web_refresher/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Web Refresher</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:88fce35323996a71b86623ff97b9a099bd381b6c37a3cb2ca6ba41179c04926d
!! source digest: sha256:f8d8ed8f9762830a5153097507a407ee9523c05093d1b424ae19dc30ccef9486
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_refresher"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_refresher"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a button next to the pager (in trees/kanban views) to refresh the displayed list.</p>
Expand Down
28 changes: 28 additions & 0 deletions web_refresher/static/src/js/client_action_adapter.esm.js
Original file line number Diff line number Diff line change
@@ -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);
}
},
});
17 changes: 15 additions & 2 deletions web_refresher/static/src/js/refresher.esm.js
Original file line number Diff line number Diff line change
@@ -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});
}
}

Expand Down

0 comments on commit 4d3274a

Please sign in to comment.