Skip to content

Commit 5bb7c4b

Browse files
committed
fix error: env.services.rpc is not a function
1 parent 143837b commit 5bb7c4b

File tree

4 files changed

+55
-52
lines changed

4 files changed

+55
-52
lines changed

web_ir_actions_act_window_message/README.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=========================
62
Client side message boxes
73
=========================
@@ -17,7 +13,7 @@ Client side message boxes
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
@@ -91,8 +87,8 @@ You are responsible for translating the messages.
9187
Known issues / Roadmap
9288
======================
9389

94-
- add message_type to differenciate between warnings, errors, etc.
95-
- have one message_type to show a nonmodal warning on top right
90+
- add message_type to differenciate between warnings, errors, etc.
91+
- have one message_type to show a nonmodal warning on top right
9692

9793
Bug Tracker
9894
===========
@@ -116,16 +112,16 @@ Authors
116112
Contributors
117113
------------
118114

119-
- Holger Brunn <hbrunn@therp.nl>
120-
- Zakaria Makrelouf (ACSONE SA/NV) <z.makrelouf@gmail.com>
121-
- Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
122-
- Ioan Galan (Studio73) <ioan@studio73.es>
123-
- Abraham Anes (Studio73) <abraham@studio73.es>
124-
- Miguel Gandia (Studio73) <miguel@studio73.es>
125-
- `DynApps NV <https://www.dynapps.be>`__:
115+
- Holger Brunn <hbrunn@therp.nl>
116+
- Zakaria Makrelouf (ACSONE SA/NV) <z.makrelouf@gmail.com>
117+
- Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
118+
- Ioan Galan (Studio73) <ioan@studio73.es>
119+
- Abraham Anes (Studio73) <abraham@studio73.es>
120+
- Miguel Gandia (Studio73) <miguel@studio73.es>
121+
- `DynApps NV <https://www.dynapps.be>`__:
126122

127-
- Koen Loodts
128-
- Raf Ven
123+
- Koen Loodts
124+
- Raf Ven
129125

130126
Maintainers
131127
-----------

web_ir_actions_act_window_message/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
{
44
"name": "Client side message boxes",
5-
"version": "18.0.1.0.0",
5+
"version": "18.0.1.1.0",
66
"author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
77
"website": "https://github.com/OCA/web",
88
"license": "AGPL-3",

web_ir_actions_act_window_message/static/description/index.html

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Client side message boxes</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="client-side-message-boxes">
364+
<h1 class="title">Client side message boxes</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="client-side-message-boxes">
370-
<h1>Client side message boxes</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:7ce537d4c262436ca7e2b131817ed046ba5a113a8bb31c56e077546948571918
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_ir_actions_act_window_message"><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-18-0/web-18-0-web_ir_actions_act_window_message"><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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/18.0/web_ir_actions_act_window_message"><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-18-0/web-18-0-web_ir_actions_act_window_message"><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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module allows to show a message popup on the client side as result
379374
of a button.</p>
380375
<p><strong>Table of contents</strong></p>
@@ -392,7 +387,7 @@ <h1>Client side message boxes</h1>
392387
</ul>
393388
</div>
394389
<div class="section" id="usage">
395-
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
390+
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
396391
<p>Depend on this module and return</p>
397392
<pre class="code python literal-block">
398393
<span class="p">{</span><span class="w">
@@ -437,31 +432,31 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
437432
<p>You are responsible for translating the messages.</p>
438433
</div>
439434
<div class="section" id="known-issues-roadmap">
440-
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
435+
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
441436
<ul class="simple">
442437
<li>add message_type to differenciate between warnings, errors, etc.</li>
443438
<li>have one message_type to show a nonmodal warning on top right</li>
444439
</ul>
445440
</div>
446441
<div class="section" id="bug-tracker">
447-
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
442+
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
448443
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
449444
In case of trouble, please check there if your issue has already been reported.
450445
If you spotted it first, help us to smash it by providing a detailed and welcomed
451446
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_ir_actions_act_window_message%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
452447
<p>Do not contact contributors directly about support or help with technical issues.</p>
453448
</div>
454449
<div class="section" id="credits">
455-
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
450+
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
456451
<div class="section" id="authors">
457-
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
452+
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
458453
<ul class="simple">
459454
<li>Therp BV</li>
460455
<li>ACSONE SA/NV</li>
461456
</ul>
462457
</div>
463458
<div class="section" id="contributors">
464-
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
459+
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
465460
<ul class="simple">
466461
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
467462
<li>Zakaria Makrelouf (ACSONE SA/NV) &lt;<a class="reference external" href="mailto:z.makrelouf&#64;gmail.com">z.makrelouf&#64;gmail.com</a>&gt;</li>
@@ -477,7 +472,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
477472
</ul>
478473
</div>
479474
<div class="section" id="maintainers">
480-
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
475+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
481476
<p>This module is maintained by the OCA.</p>
482477
<a class="reference external image-reference" href="https://odoo-community.org">
483478
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -490,6 +485,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
490485
</div>
491486
</div>
492487
</div>
493-
</div>
494488
</body>
495489
</html>

web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_msg_component.esm.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import {Component, onWillStart, useState} from "@odoo/owl";
1+
import {Component, onWillStart, useEnv, useState} from "@odoo/owl";
22
import {Dialog} from "@web/core/dialog/dialog";
33
import {_t} from "@web/core/l10n/translation";
4+
import {useService} from "@web/core/utils/hooks";
5+
import {router} from "@web/core/browser/router";
46

57
export class ActWindowMessageDialog extends Component {
68
setup() {
9+
this.env = useEnv();
10+
this.orm = useService("orm");
711
this.state = useState({
812
buttons: [],
913
});
@@ -16,21 +20,25 @@ export class ActWindowMessageDialog extends Component {
1620

1721
_refreshWidget(env) {
1822
const controller = env.services.action.currentController;
19-
const state = env.services.router.current.hash;
23+
const state = router.current;
2024
const props = controller.props;
21-
env.services.action.switchView(props.type, {resId: state.id});
25+
env.services.action
26+
.switchView(props.type, {
27+
resId: state.resId,
28+
})
29+
.catch((err) => {
30+
console.error("Error updating the view:", err);
31+
window.location.reload();
32+
});
2233
}
2334

2435
generateButtons() {
2536
var self = this;
2637
const action = self.props.action;
27-
const env = self.props.env;
2838
if (action.close_button_title !== false) {
2939
self.state.buttons.push({
3040
name: action.close_button_title || _t("Close"),
3141
click: () => {
32-
// Refresh the view before closing the dialog
33-
self._refreshWidget(env);
3442
self.props.close();
3543
},
3644
classes: "btn btn-default",
@@ -43,23 +51,28 @@ export class ActWindowMessageDialog extends Component {
4351
classes: button.classes || "btn btn-default",
4452
click: () => {
4553
if (button.type === "method") {
46-
env.services
47-
.rpc("/web/dataset/call_button", {
48-
model: button.model,
49-
method: button.method,
50-
args: button.args,
51-
kwargs: button.kwargs,
52-
})
53-
.then(function (result) {
54+
self.orm
55+
.call(
56+
button.model,
57+
button.method,
58+
button.args,
59+
button.kwargs
60+
)
61+
.then((result) => {
5462
if (typeof result === "object") {
55-
return env.services.action.doAction(result);
63+
return self.env.services.action
64+
.doAction(result)
65+
.then(() => {
66+
self.props.close();
67+
});
5668
}
57-
self._refreshWidget(env);
69+
self._refreshWidget(self.env);
5870
});
5971
} else {
60-
return env.services.action.doAction(button);
72+
return self.env.services.action.doAction(button).then(() => {
73+
self.props.close();
74+
});
6175
}
62-
self.props.close();
6376
},
6477
};
6578
self.state.buttons.push(button_data);

0 commit comments

Comments
 (0)