Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions web_ir_actions_act_window_message/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Client side message boxes
=========================
Expand All @@ -17,7 +13,7 @@ Client side message boxes
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
Expand Down Expand Up @@ -91,8 +87,8 @@ You are responsible for translating the messages.
Known issues / Roadmap
======================

- add message_type to differenciate between warnings, errors, etc.
- have one message_type to show a nonmodal warning on top right
- add message_type to differenciate between warnings, errors, etc.
- have one message_type to show a nonmodal warning on top right

Bug Tracker
===========
Expand All @@ -116,16 +112,17 @@ Authors
Contributors
------------

- Holger Brunn <hbrunn@therp.nl>
- Zakaria Makrelouf (ACSONE SA/NV) <z.makrelouf@gmail.com>
- Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
- Ioan Galan (Studio73) <ioan@studio73.es>
- Abraham Anes (Studio73) <abraham@studio73.es>
- Miguel Gandia (Studio73) <miguel@studio73.es>
- `DynApps NV <https://www.dynapps.be>`__:

- Koen Loodts
- Raf Ven
- Holger Brunn <hbrunn@therp.nl>
- Zakaria Makrelouf (ACSONE SA/NV) <z.makrelouf@gmail.com>
- Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
- Ioan Galan (Studio73) <ioan@studio73.es>
- Abraham Anes (Studio73) <abraham@studio73.es>
- Miguel Gandia (Studio73) <miguel@studio73.es>
- Sergio Martínez (Studio73) <sergio.martinez@studio73.es>
- `DynApps NV <https://www.dynapps.be>`__:

- Koen Loodts
- Raf Ven

Maintainers
-----------
Expand Down
2 changes: 2 additions & 0 deletions web_ir_actions_act_window_message/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Ioan Galan (Studio73) \<<ioan@studio73.es>\>
- Abraham Anes (Studio73) \<<abraham@studio73.es>\>
- Miguel Gandia (Studio73) \<<miguel@studio73.es>\>
- Sergio Martínez (Studio73) \<<sergio.martinez@studio73.es>\>
- [DynApps NV](https://www.dynapps.be):
- Koen Loodts
- Raf Ven

29 changes: 12 additions & 17 deletions web_ir_actions_act_window_message/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Client side message boxes</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="client-side-message-boxes">
<h1 class="title">Client side message boxes</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="client-side-message-boxes">
<h1>Client side message boxes</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7ce537d4c262436ca7e2b131817ed046ba5a113a8bb31c56e077546948571918
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<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>
<p>This module allows to show a message popup on the client side as result
of a button.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -392,7 +387,7 @@ <h1>Client side message boxes</h1>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Depend on this module and return</p>
<pre class="code python literal-block">
<span class="p">{</span><span class="w">
Expand Down Expand Up @@ -437,38 +432,39 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<p>You are responsible for translating the messages.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>add message_type to differenciate between warnings, errors, etc.</li>
<li>have one message_type to show a nonmodal warning on top right</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Therp BV</li>
<li>ACSONE SA/NV</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
<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>
<li>Benjamin Willig (ACSONE SA/NV) &lt;<a class="reference external" href="mailto:benjamin.willig&#64;acsone.eu">benjamin.willig&#64;acsone.eu</a>&gt;</li>
<li>Ioan Galan (Studio73) &lt;<a class="reference external" href="mailto:ioan&#64;studio73.es">ioan&#64;studio73.es</a>&gt;</li>
<li>Abraham Anes (Studio73) &lt;<a class="reference external" href="mailto:abraham&#64;studio73.es">abraham&#64;studio73.es</a>&gt;</li>
<li>Miguel Gandia (Studio73) &lt;<a class="reference external" href="mailto:miguel&#64;studio73.es">miguel&#64;studio73.es</a>&gt;</li>
<li>Sergio Martínez (Studio73) &lt;<a class="reference external" href="mailto:sergio.martinez&#64;studio73.es">sergio.martinez&#64;studio73.es</a>&gt;</li>
<li><a class="reference external" href="https://www.dynapps.be">DynApps NV</a>:<ul>
<li>Koen Loodts</li>
<li>Raf Ven</li>
Expand All @@ -477,7 +473,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -490,6 +486,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function openDialog({env, action}) {
action: action,
is_html_message: action.is_html_message,
size: "md",
env: env,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {Component, onWillStart, useState} from "@odoo/owl";
import {Dialog} from "@web/core/dialog/dialog";
import {_t} from "@web/core/l10n/translation";
import {useService} from "@web/core/utils/hooks";
import {router} from "@web/core/browser/router";

export class ActWindowMessageDialog extends Component {
setup() {
this.orm = useService("orm");
this.action = useService("action");
this.state = useState({
buttons: [],
});
Expand All @@ -14,23 +18,28 @@ export class ActWindowMessageDialog extends Component {
this.generateButtons();
}

_refreshWidget(env) {
const controller = env.services.action.currentController;
const state = env.services.router.current.hash;
_refreshWidget() {
const controller = this.action.currentController;
const state = router.current;
const props = controller.props;
env.services.action.switchView(props.type, {resId: state.id});
this.action
.switchView(props.type, {
resId: state.resId,
})
.catch((err) => {
console.error("Error updating the view:", err);
window.location.reload();
});
}

generateButtons() {
var self = this;
const action = self.props.action;
const env = self.props.env;
if (action.close_button_title !== false) {
self.state.buttons.push({
name: action.close_button_title || _t("Close"),
click: () => {
// Refresh the view before closing the dialog
self._refreshWidget(env);
Comment thread
hbrunn marked this conversation as resolved.
self._refreshWidget();
self.props.close();
},
classes: "btn btn-default",
Expand All @@ -43,23 +52,26 @@ export class ActWindowMessageDialog extends Component {
classes: button.classes || "btn btn-default",
click: () => {
if (button.type === "method") {
env.services
.rpc("/web/dataset/call_button", {
model: button.model,
method: button.method,
args: button.args,
kwargs: button.kwargs,
})
.then(function (result) {
self.orm
.call(
button.model,
button.method,
button.args,
button.kwargs
)
.then((result) => {
if (typeof result === "object") {
return env.services.action.doAction(result);
return self.action.doAction(result).then(() => {
self.props.close();
});
}
self._refreshWidget(env);
self._refreshWidget();
});
} else {
return env.services.action.doAction(button);
return self.action.doAction(button).then(() => {
self.props.close();
});
}
self.props.close();
},
};
self.state.buttons.push(button_data);
Expand All @@ -82,7 +94,6 @@ ActWindowMessageDialog.props = {
optional: true,
},
action: {type: Object, optional: true},
env: {type: Object, optional: true},
is_html_message: {type: Boolean, optional: true},
size: {type: String},
close: Function,
Expand Down