From dcfa784ab08c10262b72959de83712cabe6b56fc Mon Sep 17 00:00:00 2001 From: Andreu Orensanz Date: Fri, 9 Jan 2026 16:39:28 +0100 Subject: [PATCH] [ADD] mail_chatter_split --- mail_chatter_split/README.rst | 88 ++++ mail_chatter_split/__init__.py | 1 + mail_chatter_split/__manifest__.py | 26 ++ mail_chatter_split/pyproject.toml | 6 + mail_chatter_split/readme/CONTRIBUTORS.md | 2 + mail_chatter_split/readme/DESCRIPTION.md | 8 + .../static/description/index.html | 436 ++++++++++++++++++ .../static/src/activity_list_patch.xml | 13 + .../static/src/chatter.dark.scss | 11 + mail_chatter_split/static/src/chatter.scss | 25 + .../static/src/chatter_patch.esm.js | 53 +++ .../static/src/chatter_patch.xml | 66 +++ .../static/src/thread_model_patch.esm.js | 83 ++++ .../static/src/thread_patch.esm.js | 18 + .../static/src/thread_patch.xml | 10 + 15 files changed, 846 insertions(+) create mode 100644 mail_chatter_split/README.rst create mode 100644 mail_chatter_split/__init__.py create mode 100644 mail_chatter_split/__manifest__.py create mode 100644 mail_chatter_split/pyproject.toml create mode 100644 mail_chatter_split/readme/CONTRIBUTORS.md create mode 100644 mail_chatter_split/readme/DESCRIPTION.md create mode 100644 mail_chatter_split/static/description/index.html create mode 100644 mail_chatter_split/static/src/activity_list_patch.xml create mode 100644 mail_chatter_split/static/src/chatter.dark.scss create mode 100644 mail_chatter_split/static/src/chatter.scss create mode 100644 mail_chatter_split/static/src/chatter_patch.esm.js create mode 100644 mail_chatter_split/static/src/chatter_patch.xml create mode 100644 mail_chatter_split/static/src/thread_model_patch.esm.js create mode 100644 mail_chatter_split/static/src/thread_patch.esm.js create mode 100644 mail_chatter_split/static/src/thread_patch.xml diff --git a/mail_chatter_split/README.rst b/mail_chatter_split/README.rst new file mode 100644 index 000000000..78a12c472 --- /dev/null +++ b/mail_chatter_split/README.rst @@ -0,0 +1,88 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================== +Mail Chatter Split +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3e57ebfa82878d78814145be1ee59a19768598f6b3b0fc182c932b6e91b0d188 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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 + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github + :target: https://github.com/OCA/mail/tree/17.0/mail_chatter_split + :alt: OCA/mail +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/mail-17-0/mail-17-0-mail_chatter_split + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module introduces filter buttons in the chatter to separate user +messages, activities and system logs. It adds a small toggle toolbar +above the chatter that allows switching between: + +- All messages: default view showing all messages +- User messages: only user-generated messages +- System logs: only system-generated logs +- Planned activities: only activities + +Also, it keeps the chatter view selected when navigating between +records/views, similar to how notebook tabs in form views remember the +last selected tab. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +- `ForgeFlow `__: + + - Andreu Orensanz + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/mail `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_chatter_split/__init__.py b/mail_chatter_split/__init__.py new file mode 100644 index 000000000..6d4f4bde9 --- /dev/null +++ b/mail_chatter_split/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/mail_chatter_split/__manifest__.py b/mail_chatter_split/__manifest__.py new file mode 100644 index 000000000..2b08a3d3e --- /dev/null +++ b/mail_chatter_split/__manifest__.py @@ -0,0 +1,26 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Mail Chatter Split", + "summary": "Separate user messages, activities and automatic logs in the chatter", + "version": "17.0.1.0.0", + "category": "Social Network", + "website": "https://github.com/OCA/mail", + "author": "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["mail"], + "assets": { + "web.assets_backend": [ + "mail_chatter_split/static/src/chatter_patch.esm.js", + "mail_chatter_split/static/src/chatter_patch.xml", + "mail_chatter_split/static/src/activity_list_patch.xml", + "mail_chatter_split/static/src/chatter.scss", + "mail_chatter_split/static/src/thread_model_patch.esm.js", + "mail_chatter_split/static/src/thread_patch.esm.js", + "mail_chatter_split/static/src/thread_patch.xml", + ], + "web.assets_web_dark": [ + "mail_chatter_split/static/src/chatter.dark.scss", + ], + }, +} diff --git a/mail_chatter_split/pyproject.toml b/mail_chatter_split/pyproject.toml new file mode 100644 index 000000000..9bc25a281 --- /dev/null +++ b/mail_chatter_split/pyproject.toml @@ -0,0 +1,6 @@ +[project] +name = "odoo-addon-mail_chatter_split" + +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_chatter_split/readme/CONTRIBUTORS.md b/mail_chatter_split/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..313a35836 --- /dev/null +++ b/mail_chatter_split/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [ForgeFlow](https://www.forgeflow.com): + - Andreu Orensanz \<\> diff --git a/mail_chatter_split/readme/DESCRIPTION.md b/mail_chatter_split/readme/DESCRIPTION.md new file mode 100644 index 000000000..fde4507c0 --- /dev/null +++ b/mail_chatter_split/readme/DESCRIPTION.md @@ -0,0 +1,8 @@ +This module introduces filter buttons in the chatter to separate user messages, activities and system logs. +It adds a small toggle toolbar above the chatter that allows switching between: +- All messages: default view showing all messages +- User messages: only user-generated messages +- System logs: only system-generated logs +- Planned activities: only activities + +Also, it keeps the chatter view selected when navigating between records/views, similar to how notebook tabs in form views remember the last selected tab. diff --git a/mail_chatter_split/static/description/index.html b/mail_chatter_split/static/description/index.html new file mode 100644 index 000000000..89e9af23e --- /dev/null +++ b/mail_chatter_split/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Mail Chatter Split

+ +

Beta License: AGPL-3 OCA/mail Translate me on Weblate Try me on Runboat

+

This module introduces filter buttons in the chatter to separate user +messages, activities and system logs. It adds a small toggle toolbar +above the chatter that allows switching between:

+
    +
  • All messages: default view showing all messages
  • +
  • User messages: only user-generated messages
  • +
  • System logs: only system-generated logs
  • +
  • Planned activities: only activities
  • +
+

Also, it keeps the chatter view selected when navigating between +records/views, similar to how notebook tabs in form views remember the +last selected tab.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/mail project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/mail_chatter_split/static/src/activity_list_patch.xml b/mail_chatter_split/static/src/activity_list_patch.xml new file mode 100644 index 000000000..42b766eb6 --- /dev/null +++ b/mail_chatter_split/static/src/activity_list_patch.xml @@ -0,0 +1,13 @@ + + + + + props.hasActivities and activities.length and !state.isSearchOpen and (state.chatterView === 'all' or state.chatterView === 'activities') + + + diff --git a/mail_chatter_split/static/src/chatter.dark.scss b/mail_chatter_split/static/src/chatter.dark.scss new file mode 100644 index 000000000..536cfe3bf --- /dev/null +++ b/mail_chatter_split/static/src/chatter.dark.scss @@ -0,0 +1,11 @@ +.o-mail-ChatterSplit-tabs { + .btn-group { + .btn { + &.btn-outline-secondary { + &:hover { + background-color: $o-gray-400; + } + } + } + } +} diff --git a/mail_chatter_split/static/src/chatter.scss b/mail_chatter_split/static/src/chatter.scss new file mode 100644 index 000000000..a89bf58a5 --- /dev/null +++ b/mail_chatter_split/static/src/chatter.scss @@ -0,0 +1,25 @@ +.o-mail-ChatterSplit-tabs { + background-color: var(--o-view-background-color, #fff); + border-bottom: 1px solid var(--o-border-color, #dee2e6); + + .btn-group { + .btn { + font-size: 0.85rem; + padding: 0.25rem 0.75rem; + + &.btn-primary { + box-shadow: none; + } + + &.btn-outline-secondary { + &:hover { + background-color: var(--o-gray-200, #e9ecef); + } + } + + i { + font-size: 0.8rem; + } + } + } +} diff --git a/mail_chatter_split/static/src/chatter_patch.esm.js b/mail_chatter_split/static/src/chatter_patch.esm.js new file mode 100644 index 000000000..db0f0c1d9 --- /dev/null +++ b/mail_chatter_split/static/src/chatter_patch.esm.js @@ -0,0 +1,53 @@ +/** @odoo-module */ + +import {Chatter} from "@mail/core/web/chatter"; +import {browser} from "@web/core/browser/browser"; +import {patch} from "@web/core/utils/patch"; +import {useEffect} from "@odoo/owl"; + +const CHATTER_VIEW_STORAGE_KEY = "mail_chatter_split.chatterView"; + +patch(Chatter.prototype, { + setup() { + super.setup(); + const storedView = browser.sessionStorage.getItem(CHATTER_VIEW_STORAGE_KEY); + this.state.chatterView = storedView || "all"; + useEffect( + (thread, chatterView) => { + if (thread && chatterView) { + thread.chatterViewMode = chatterView; + } + }, + () => [this.state.thread, this.state.chatterView] + ); + }, + + /** + * Switch the chatter view to show all, messages only, logs only, or activities only + * @param {String} view - 'all', 'messages', 'logs', or 'activities' + */ + setChatterView(view) { + this.state.chatterView = view; + // Persist the chatter view selection to sessionStorage + browser.sessionStorage.setItem(CHATTER_VIEW_STORAGE_KEY, view); + if (this.state.thread) { + this.state.thread.chatterViewMode = view; + } + }, + + get isViewAll() { + return this.state.chatterView === "all"; + }, + + get isViewMessages() { + return this.state.chatterView === "messages"; + }, + + get isViewLogs() { + return this.state.chatterView === "logs"; + }, + + get isViewActivities() { + return this.state.chatterView === "activities"; + }, +}); diff --git a/mail_chatter_split/static/src/chatter_patch.xml b/mail_chatter_split/static/src/chatter_patch.xml new file mode 100644 index 000000000..4e2646acf --- /dev/null +++ b/mail_chatter_split/static/src/chatter_patch.xml @@ -0,0 +1,66 @@ + + + + +
+
+ + + + +
+
+
+
+
diff --git a/mail_chatter_split/static/src/thread_model_patch.esm.js b/mail_chatter_split/static/src/thread_model_patch.esm.js new file mode 100644 index 000000000..3aec4c165 --- /dev/null +++ b/mail_chatter_split/static/src/thread_model_patch.esm.js @@ -0,0 +1,83 @@ +/** @odoo-module */ + +import {Record} from "@mail/core/common/record"; +import {Thread} from "@mail/core/common/thread_model"; + +import {patch} from "@web/core/utils/patch"; + +patch(Thread.prototype, { + update(data) { + super.update(data); + if (this.chatterViewMode === undefined) { + this.chatterViewMode = "all"; + } + }, +}); + +Thread.prototype.chatterViewMode = Record.attr("all"); + +Object.defineProperty(Thread.prototype, "displayedMessages", { + get() { + const messages = this.nonEmptyMessages; + if (!this.chatterViewMode || this.chatterViewMode === "all") { + return messages; + } + if (this.chatterViewMode === "messages") { + return messages.filter((msg) => this._isUserMessage(msg)); + } + if (this.chatterViewMode === "logs") { + return messages.filter((msg) => this._isLogMessage(msg)); + } + if (this.chatterViewMode === "activities") { + return messages.filter((msg) => this._isActivity(msg)); + } + return messages; + }, + configurable: true, +}); + +/** + * Check if a message is a user-generated message + * @param {Object} msg + * @returns {Boolean} + */ +Thread.prototype._isUserMessage = function (msg) { + const userTypes = ["comment", "email", "email_outgoing"]; + if (userTypes.includes(msg.type)) { + return true; + } + if (["auto_comment", "user_notification"].includes(msg.type) && !msg.isBodyEmpty) { + return true; + } + return false; +}; + +/** + * Check if a message is a system-generated log + * @param {Object} msg + * @returns {Boolean} + */ +Thread.prototype._isLogMessage = function (msg) { + if (msg.type === "notification") { + return true; + } + if (msg.trackingValues && msg.trackingValues.length > 0) { + return true; + } + if (msg.isBodyEmpty && msg.subtype_description) { + return true; + } + return false; +}; + +/** + * Check if a message is an activity + * @param {Object} msg + * @returns {Boolean} + */ +Thread.prototype._isActivity = function (msg) { + return ( + msg.type === "user_notification" || + (msg.subtype_description && msg.subtype_description.includes("Activity")) + ); +}; diff --git a/mail_chatter_split/static/src/thread_patch.esm.js b/mail_chatter_split/static/src/thread_patch.esm.js new file mode 100644 index 000000000..0a7201e72 --- /dev/null +++ b/mail_chatter_split/static/src/thread_patch.esm.js @@ -0,0 +1,18 @@ +/** @odoo-module */ + +import {Thread} from "@mail/core/common/thread"; +import {patch} from "@web/core/utils/patch"; + +patch(Thread.prototype, { + /** + * Get messages to display, applying the chatter view mode filter if set + * @returns {Array} + */ + getMessagesToDisplay() { + const thread = this.props.thread; + if (!thread) { + return []; + } + return thread.displayedMessages || thread.nonEmptyMessages; + }, +}); diff --git a/mail_chatter_split/static/src/thread_patch.xml b/mail_chatter_split/static/src/thread_patch.xml new file mode 100644 index 000000000..df1bf7024 --- /dev/null +++ b/mail_chatter_split/static/src/thread_patch.xml @@ -0,0 +1,10 @@ + + + + + props.order === 'asc' ? this.getMessagesToDisplay() : [...this.getMessagesToDisplay()].reverse() + + +