diff --git a/mail_chatter_split/README.rst b/mail_chatter_split/README.rst new file mode 100644 index 000000000..8b58d1cab --- /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:2d4e4e0d9ac3c89ec8fab7fc33b92bc53b07a02f100f0a18c8d2ab70d06fd072 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/19.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-19-0/mail-19-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=19.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..dc3705f4a --- /dev/null +++ b/mail_chatter_split/__manifest__.py @@ -0,0 +1,25 @@ +# 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": "19.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", + ], + "web.assets_web_dark": [ + "mail_chatter_split/static/src/chatter.dark.scss", + ], + }, +} diff --git a/mail_chatter_split/i18n/it.po b/mail_chatter_split/i18n/it.po new file mode 100644 index 000000000..80b678461 --- /dev/null +++ b/mail_chatter_split/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_chatter_split +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-02-11 10:09+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Activities" +msgstr "Attività" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "All" +msgstr "Tutti" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Chatter view toggle" +msgstr "Mostra/nascondi elenco messaggi" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Logs" +msgstr "Log" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Messages" +msgstr "Messaggi" diff --git a/mail_chatter_split/i18n/mail_chatter_split.pot b/mail_chatter_split/i18n/mail_chatter_split.pot new file mode 100644 index 000000000..62f0c1037 --- /dev/null +++ b/mail_chatter_split/i18n/mail_chatter_split.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_chatter_split +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Activities" +msgstr "" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "All" +msgstr "" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Chatter view toggle" +msgstr "" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Logs" +msgstr "" + +#. module: mail_chatter_split +#. odoo-javascript +#: code:addons/mail_chatter_split/static/src/chatter_patch.xml:0 +#, python-format +msgid "Messages" +msgstr "" 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/icon.png b/mail_chatter_split/static/description/icon.png new file mode 100644 index 000000000..1dcc49c24 Binary files /dev/null and b/mail_chatter_split/static/description/icon.png differ diff --git a/mail_chatter_split/static/description/index.html b/mail_chatter_split/static/description/index.html new file mode 100644 index 000000000..89338a0d7 --- /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..23e4c236d --- /dev/null +++ b/mail_chatter_split/static/src/activity_list_patch.xml @@ -0,0 +1,13 @@ + + + + + props.has_activities and activities.length and !messageSearch.searching and !messageSearch.searched 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..b7c5a7c3c --- /dev/null +++ b/mail_chatter_split/static/src/chatter.scss @@ -0,0 +1,24 @@ +.o-mail-ChatterSplit-tabs { + background-color: $o-webclient-background-color; + + .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..201d45ab4 --- /dev/null +++ b/mail_chatter_split/static/src/chatter_patch.esm.js @@ -0,0 +1,51 @@ +import {Chatter} from "@mail/chatter/web_portal/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..d90ce46b1 --- /dev/null +++ b/mail_chatter_split/static/src/chatter_patch.xml @@ -0,0 +1,63 @@ + + + + +
+
+ + + + +
+
+
+
+
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..5da19b4a2 --- /dev/null +++ b/mail_chatter_split/static/src/thread_model_patch.esm.js @@ -0,0 +1,78 @@ +import {Thread} from "@mail/core/common/thread_model"; +import {fields} from "@mail/core/common/record"; + +import {patch} from "@web/core/utils/patch"; + +patch(Thread.prototype, { + setup() { + super.setup(); + this.chatterViewMode = fields.Attr("all"); + }, + + get displayedMessages() { + 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; + }, + + /** + * Check if a message is a user-generated message + * @param {Object} msg + * @returns {Boolean} + */ + _isUserMessage(msg) { + const userTypes = ["comment", "email", "email_outgoing"]; + if (userTypes.includes(msg.message_type)) { + return true; + } + if ( + ["auto_comment", "user_notification"].includes(msg.message_type) && + !msg.isBodyEmpty + ) { + return true; + } + return false; + }, + + /** + * Check if a message is a system-generated log + * @param {Object} msg + * @returns {Boolean} + */ + _isLogMessage(msg) { + if (msg.message_type === "notification") { + return true; + } + if (msg.trackingValues && msg.trackingValues.length > 0) { + return true; + } + if (msg.isBodyEmpty && msg.subtype_id?.description) { + return true; + } + return false; + }, + + /** + * Check if a message is an activity + * @param {Object} msg + * @returns {Boolean} + */ + _isActivity(msg) { + return ( + msg.message_type === "user_notification" || + (msg.subtype_id?.description && + msg.subtype_id.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..2003bdf3a --- /dev/null +++ b/mail_chatter_split/static/src/thread_patch.esm.js @@ -0,0 +1,19 @@ +import {Thread} from "@mail/core/common/thread"; +import {patch} from "@web/core/utils/patch"; + +patch(Thread.prototype, { + /** + * Restrict the rendered messages to the ones matching the chatter view mode + * selected on the thread, keeping the ordering computed by the core getter. + * @returns {Array} + */ + get orderedMessages() { + const messages = super.orderedMessages; + const thread = this.props.thread; + if (!thread || !thread.chatterViewMode || thread.chatterViewMode === "all") { + return messages; + } + const displayed = new Set(thread.displayedMessages); + return messages.filter((msg) => displayed.has(msg)); + }, +});