Skip to content

[15.0][ADD] ‎mail_last_message_date#1794

Open
nobuQuartile wants to merge 1 commit into
OCA:15.0from
qrtl:15.0-add-mail_thread_last_update
Open

[15.0][ADD] ‎mail_last_message_date#1794
nobuQuartile wants to merge 1 commit into
OCA:15.0from
qrtl:15.0-add-mail_thread_last_update

Conversation

@nobuQuartile
Copy link
Copy Markdown

We sometimes need to know the last time a record’s chatter was updated (e.g., in automated actions).
Added a last_chatter_update datetime field to chatter-enabled models and implemented automatic updates on message creation.

@qrtl QT5890

@nobuQuartile nobuQuartile force-pushed the 15.0-add-mail_thread_last_update branch 2 times, most recently from 14a83b2 to 3de01b3 Compare February 10, 2026 09:46
@nobuQuartile nobuQuartile changed the title [15.0][ADD] mail_thread_last_update [15.0][ADD] ‎mail_last_chatter_update_mixin Feb 10, 2026
@nobuQuartile nobuQuartile force-pushed the 15.0-add-mail_thread_last_update branch 4 times, most recently from ddf0778 to 28352cc Compare February 12, 2026 05:02
@nobuQuartile nobuQuartile marked this pull request as ready for review February 12, 2026 05:16
Copy link
Copy Markdown

@AungKoKoLin1997 AungKoKoLin1997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nobuQuartile I’m not comfortable with the current design because other modules will need to depend on it, and the current module would also require an additional mixin model.

I believe we should create a generic module that can be reused across multiple use cases.

My idea is to add a new field on mail.thread rather than using a mixin, and then update that field when a message is created, based on the configuration we set.

We’ll also need to add configuration options in Settings and in the message subtype to control which subtypes and which models should use this feature.

How do you think that?

@nobuQuartile
Copy link
Copy Markdown
Author

@AungKoKoLin1997 CC: @yostashiro

When I discussed it directly with Yoshi last time, we agreed that we could create a new field in the mail.thread, it would end up adding a field — which may or may not be used — to all models that inherit from mail.thread.

As a result, we concluded that it would be better to implement it as a mixin module and add the field only to the models that actually need it.

Do you agree with this approach?

Comment thread mail_last_chatter_update_mixin/models/mail_last_chatter_update_mixin.py Outdated
Comment thread mail_last_chatter_update_mixin/models/mail_last_chatter_update_mixin.py Outdated
Comment thread mail_last_chatter_update_mixin/models/mail_last_chatter_update_mixin.py Outdated
Comment thread mail_last_chatter_update_mixin/models/mail_message.py Outdated
Comment thread mail_last_chatter_update_mixin/tests/test_models.py Outdated
Comment thread mail_last_chatter_update_mixin/models/mail_last_chatter_update_mixin.py Outdated
Comment thread mail_last_chatter_update_mixin/models/mail_last_chatter_update_mixin.py Outdated
continue
record = self.env[message.model].browse(message.res_id)
if (
not record.exists()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example of how this condition is needed?

Comment thread mail_last_chatter_update_mixin/models/mail_message.py Outdated
@yostashiro
Copy link
Copy Markdown
Member

Module name suggestion: mail_last_message_date

@nobuQuartile nobuQuartile force-pushed the 15.0-add-mail_thread_last_update branch from 28352cc to c5d9ace Compare February 18, 2026 03:16
Copy link
Copy Markdown
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick one. I will come back to this PR for more later. Please update the PR title accordingly.

Comment thread mail_last_message_date/models/mail_last_message_date_mixin.py Outdated
@nobuQuartile nobuQuartile changed the title [15.0][ADD] ‎mail_last_chatter_update_mixin [15.0][ADD] ‎mail_last_message_date Feb 18, 2026
@nobuQuartile nobuQuartile force-pushed the 15.0-add-mail_thread_last_update branch from c5d9ace to f7b276b Compare February 18, 2026 04:56
class PurchaseOrder(models.Model):
_inherit = ["purchase.order", "mail.last.message.date.mixin"]

def _get_tracked_message_types(self):
Copy link
Copy Markdown

@AungKoKoLin1997 AungKoKoLin1997 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since mixin model is returning []. I think there is no reason to call super().

Comment on lines +13 to +16
def _get_tracked_message_types(self):
message_types = super()._get_tracked_message_types()
message_types.append("email")
return message_types
Copy link
Copy Markdown

@AungKoKoLin1997 AungKoKoLin1997 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines +8 to +9
_name = "test.mail.last.message.date"
_inherit = ["mail.thread", "mail.last.message.date.mixin"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add description to avoid CI error when we do the future migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants