Skip to content

Commit 55a36e5

Browse files
mail_sound, eslint (#207)
* mail_sound from 15.0 * initial migration * add README, fix syntax * add pyproject.toml * remove whool from pre-commit, pyproject.toml * [18.0][MIG] Migrated the module mail_sound into v18 * [FIX] Implemented the code to pass the CI tests * [IMP] Implemented the file path of js * [IMP] Implemented the code to fixed the CI tests [IMP] Implemented the code [IMP] Implmented the code to fix the CI * [IMP] Commented the .yaml file eslint code to fix the CI * [IMP] Uncomment the .yaml file eslint code * fix path for eslint * update description * fix pylint, eslint * fix linter --------- Co-authored-by: HItesh Jadav <[email protected]>
1 parent a8bda39 commit 55a36e5

File tree

9 files changed

+92
-7
lines changed

9 files changed

+92
-7
lines changed

.pylintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ enable=anomalous-backslash-in-string,
3737
eval-used,
3838
incoherent-interpreter-exec-perm,
3939
license-allowed,
40-
manifest-author-string,
4140
manifest-deprecated-key,
4241
manifest-required-author,
4342
manifest-required-key,

ecommerce_first_last_name/static/src/js/website_sale.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @odoo-module **/
1+
/* @odoo-module */
22

33
import websiteSaleAddress from "@website_sale/js/address";
44

eslint.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const config = [{
195195
},
196196

197197
}, {
198-
files: ["**/*.esm.js", "**/*test.js", "**/static/src/js/**/*.js"],
198+
files: ["**/*.esm.js", "**/*test.js", "**/static/src/**/*.js"],
199199

200200
languageOptions: {
201201
ecmaVersion: 2024,

mail_sound/README.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
========================
2+
Mail Sound Notifications
3+
========================
4+
5+
This module enhances Odoo's notification system by ensuring that sound notifications
6+
are played for all incoming messages, regardless of the browser window's focus state.
7+
8+
**Key Features:**
9+
10+
* Plays notification sounds even when the browser window has focus
11+
* Works for channel messages, direct messages, and @mentions
12+
* Filters out sounds for self-authored messages
13+
* Seamless integration with Odoo 18.0's service-based architecture
14+
15+
**Use Case:**
16+
17+
By default, Odoo only plays notification sounds when the browser window is out of focus.
18+
This module ensures users never miss important messages by playing sounds in all cases,
19+
providing better awareness of incoming communications.
20+
21+
**Table of contents**
22+
23+
.. contents::
24+
:local:
25+
26+
Configuration
27+
=============
28+
29+
No configuration required. The module works automatically after installation.

mail_sound/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

mail_sound/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Mail Sound Notifications",
3+
"version": "18.0.1.0.0",
4+
"category": "Discuss",
5+
"summary": "Play sound when receiving messages",
6+
"author": "Nitrokey GmbH",
7+
"website": "https://github.com/Nitrokey/odoo-modules",
8+
"license": "AGPL-3",
9+
"depends": ["mail"],
10+
"data": [],
11+
"assets": {
12+
"web.assets_backend": [
13+
"mail_sound/static/src/services/out_of_focus_service_patch.js",
14+
],
15+
},
16+
"installable": True,
17+
"auto_install": False,
18+
"application": False,
19+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* @odoo-module */
2+
3+
import {OutOfFocusService} from "@mail/core/common/out_of_focus_service";
4+
import {patch} from "@web/core/utils/patch";
5+
6+
/**
7+
* Patch the OutOfFocusService to always play notification sounds
8+
* regardless of browser focus state.
9+
*
10+
* This extends the standard notification behavior to play sounds
11+
* even when the browser window has focus, ensuring users never
12+
* miss notifications.
13+
*/
14+
patch(OutOfFocusService.prototype, {
15+
/**
16+
* Override notify to always play sound for incoming messages.
17+
*
18+
* @override
19+
* @param {Object} message - The message object
20+
*/
21+
async notify(message) {
22+
// Call parent implementation to maintain standard notification behavior
23+
await super.notify(...arguments);
24+
const currentUser = this.env.services["mail.store"].self;
25+
const currentUserId = currentUser?.id;
26+
27+
// Always play sound for messages from other users
28+
// The parent notify() already handles the focus-dependent behavior,
29+
// so we add unconditional sound playback here
30+
if (message && message.author && message.author.id !== currentUserId) {
31+
// Play the notification sound using the internal _playSound method
32+
// This ensures sound plays regardless of browser focus state
33+
this._playSound();
34+
}
35+
},
36+
});

payment_bitcoin/static/src/js/bitcoin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/** @odoo-module **/
1+
/* @odoo-module */
22

3-
import publicWidget from "@web/legacy/js/public/public_widget";
43
import {_t} from "@web/core/l10n/translation";
4+
import publicWidget from "@web/legacy/js/public/public_widget";
55
import {rpc} from "@web/core/network/rpc";
66

77
// In Odoo 18, the frontend payment form widget is PaymentForm in the publicWidget registry.

payment_bitcoin/static/src/js/countdown.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @odoo-module **/
1+
/* @odoo-module */
22

33
import publicWidget from "@web/legacy/js/public/public_widget";
44

@@ -24,7 +24,8 @@ publicWidget.registry.reloadDuration = publicWidget.Widget.extend({
2424
let seconds = secondsNode ? parseInt(secondsNode.textContent || "0", 10) : 0;
2525
const timeCounter = document.getElementById("timecounter");
2626
if (!timeCounter) {
27-
return; // Nothing to update.
27+
// Nothing to update.
28+
return;
2829
}
2930
timeCounter.style.fontSize = "60px";
3031

0 commit comments

Comments
 (0)