Skip to content
Draft
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
97 changes: 97 additions & 0 deletions mail_thread_last_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=======================
Mail Thread Last Update
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1d44e96513bb20b72974dbb2b2d77c74dbc11329e00d20b702fcee4af31d540a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/15.0/mail_thread_last_update
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_thread_last_update
: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/social&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a last chatter update datetime (``last_chatter_update``)
to models with chatter support.
The models to update and the message types to use are controlled by system
parameters.

**Table of contents**

.. contents::
:local:

Configuration
=============

#. Navigate to *Settings > Technical > Parameters > System Parameters*.
#. Set ``mail_thread_last_update.target_models`` to a comma-separated list of model names.
#. If ``mail_thread_last_update.target_models`` is empty, any chatter-enabled model will update ``last_chatter_update``.
#. Set ``mail_thread_last_update.message_types`` to a comma-separated list of message types.
#. If ``mail_thread_last_update.message_types`` is empty, any message type will update ``last_chatter_update``.
#. Example values:
``helpdesk.ticket,res.partner`` / ``comment,email,note``

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mail_thread_last_update%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Quartile

Contributors
~~~~~~~~~~~~

* `Quartile <https://www.quartile.co>`__:

* Toshikimi Shigenobu
* Yoshi Tashiro

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/social <https://github.com/OCA/social/tree/15.0/mail_thread_last_update>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions mail_thread_last_update/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
15 changes: 15 additions & 0 deletions mail_thread_last_update/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Mail Thread Last Update",
"version": "15.0.1.0.0",
"category": "Mail",
"author": "Quartile, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/social",
"depends": ["mail"],
"data": [
"data/ir_config_parameter.xml",
],
"installable": True,
}
11 changes: 11 additions & 0 deletions mail_thread_last_update/data/ir_config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="param_mail_thread_last_update_target_models" model="ir.config_parameter">
<field name="key">mail_thread_last_update.target_models</field>
<field name="value"></field>
</record>
<record id="param_mail_thread_last_update_message_types" model="ir.config_parameter">
<field name="key">mail_thread_last_update.message_types</field>
<field name="value"></field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions mail_thread_last_update/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import mail_message
from . import mail_thread
38 changes: 38 additions & 0 deletions mail_thread_last_update/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MailMessage(models.Model):
_inherit = "mail.message"

@api.model_create_multi
def create(self, vals_list):
messages = super().create(vals_list)
messages._update_last_chatter_update()
return messages

def _update_last_chatter_update(self):
params = self.env["ir.config_parameter"].sudo()
models_value = (params.get_param("mail_thread_last_update.target_models") or "").strip()
types_value = (params.get_param("mail_thread_last_update.message_types") or "").strip()

target_models = {item.strip() for item in models_value.split(",") if item.strip()}
message_types = {item.strip() for item in types_value.split(",") if item.strip()}

for message in self:
is_target = (
message.model
and message.res_id
and (not target_models or message.model in target_models)
and (not message_types or message.message_type in message_types)
)
if not is_target:
continue

record = self.env[message.model].browse(message.res_id)
if record.exists() and hasattr(record, "last_chatter_update"):
record.sudo().write({
"last_chatter_update": message.date or fields.Datetime.now(),
})
13 changes: 13 additions & 0 deletions mail_thread_last_update/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class MailThread(models.AbstractModel):
_inherit = "mail.thread"

last_chatter_update = fields.Datetime(
string="Last Chatter Update",
help="Datetime when a message was posted on the record.",
)
7 changes: 7 additions & 0 deletions mail_thread_last_update/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#. Navigate to *Settings > Technical > Parameters > System Parameters*.
#. Set ``mail_thread_last_update.target_models`` to a comma-separated list of model names.
#. If ``mail_thread_last_update.target_models`` is empty, any chatter-enabled model will update ``last_chatter_update``.
#. Set ``mail_thread_last_update.message_types`` to a comma-separated list of message types.
#. If ``mail_thread_last_update.message_types`` is empty, any message type will update ``last_chatter_update``.
#. Example values:
``helpdesk.ticket,res.partner`` / ``comment,email,note``
4 changes: 4 additions & 0 deletions mail_thread_last_update/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Quartile <https://www.quartile.co>`__:

* Toshikimi Shigenobu
* Yoshi Tashiro
4 changes: 4 additions & 0 deletions mail_thread_last_update/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module adds a last chatter update datetime (``last_chatter_update``)
to models with chatter support.
The models to update and the message types to use are controlled by system
parameters.
Loading
Loading