Skip to content

[20.0][MIG] mail_tracking: Migration to 20.0 and rename to mail_recipient_tracking - #8

Merged
alan196 merged 118 commits into
Jarsa:20.0from
Jarsa-dev:20.0-mig-mail_recipient_tracking
Nov 30, 2026
Merged

alan196 merged 118 commits into
Jarsa:20.0from
Jarsa-dev:20.0-mig-mail_recipient_tracking

Conversation

@alan196

@alan196 alan196 commented Nov 30, 2026

Copy link
Copy Markdown

Trae a Jarsa/mail 20.0 la migración de OCA (OCA#310), con cherry-pick sobre jarsa/20.0.

🤖 Generated with Claude Code

antespi and others added 30 commits November 30, 2026 15:42
* [ADD] mail_tracking addon

* Add description icon

* Fixes remarked

* Fix Travis error

* Remarks fixed
…ent events (OCA#82)

[IMP] mail_tracking: Speed installation time, discard concurrent events and other fixes
* Improve tests
* Show trackings even if partner removed
* Disable CSRF protection to webhooks controllers
As regular users can't access this object.
* [FIX] Only one data-odoo-tracking-email tag in each email
* [FIX] Get status even in multicompany instances
On our server,
queries based on "mail_tracking_event"."tracking_email_id" improved from 501,924 ms to 1,840 ms
queries based on "mail_tracking_email"."mail_message_id" improved from 167,436 ms to 3,223 ms

The last ones are run several times when a thread has many messages
Currently translated at 100.0% (82 of 82 strings)

Translation: social-11.0/social-11.0-mail_tracking
Translate-URL: https://translation.odoo-community.org/projects/social-11-0/social-11-0-mail_tracking/fr/
For giving more priority to other buttons like the invoices one.
Currently translated at 96.3% (79 of 82 strings)

Translation: social-11.0/social-11.0-mail_tracking
Translate-URL: https://translation.odoo-community.org/projects/social-11-0/social-11-0-mail_tracking/ca/
Or infinite recursions will happen on other `write` overwrites, like the one that happens
on `mass_mailing_partner`.
trisdoan and others added 28 commits November 30, 2026 15:44
…peruser

The previous condition to apply access restriction to mail tracking
email records was not applied to every user having access rights
settings. Hence, this could lead up to AccessError when trying
to open the model's action through the web client.

Since the access to these records is based on the same restrictions
that are implemented for mail.message model in the mail module,
we ended up having access error as there were records we were
allowed to search but not to read, due to the restriction being more
permissive in the case of mail tracking email.

But since the check_access method of this model is actually checking
if the user has access to the related mail.message, we need to have
the same conditions to avoid such access error for users with settings
access that are not superuser.
This prop was removed during the migration to 18.0 (974b492), probably by
mistake, and yet causing this regression.

The `onUpdate` prop is used here:
https://github.com/OCA/mail/blob/b0226505/mail_tracking/static/src/core/chatter/chatter.xml#L34

And so the UI breaks whene trying to render a thread that contains failed
messages.

Traceback:

```
UncaughtPromiseError > OwlError
Uncaught Promise > Invalid props for component 'FailedMessage': unknown key 'onUpdate'
Occured on localhost:8069 on 2025-09-04 17:57:30 GMT
OwlError: Invalid props for component 'FailedMessage': unknown key 'onUpdate'
    Error: Invalid props for component 'FailedMessage': unknown key 'onUpdate'
        at Object.validateProps (http://localhost:8069/web/assets/debug/web.assets_web.js:11207:19) (/web/static/lib/owl/owl.js:3214)
        at Chatter.template (eval at compile (http://localhost:8069/web/assets/debug/web.assets_web.js:13754:20), <anonymous>:30:17) (/web/static/lib/owl/owl.js:5761)
        at Chatter.template (eval at compile (http://localhost:8069/web/assets/debug/web.assets_web.js:13754:20), <anonymous>:194:30) (/web/static/lib/owl/owl.js:5761)
        at Fiber._render (http://localhost:8069/web/assets/debug/web.assets_web.js:9776:38) (/web/static/lib/owl/owl.js:1783)
        at Fiber.render (http://localhost:8069/web/assets/debug/web.assets_web.js:9768:18) (/web/static/lib/owl/owl.js:1775)
        at ComponentNode.updateAndRender (http://localhost:8069/web/assets/debug/web.assets_web.js:10564:19) (/web/static/lib/owl/owl.js:2571)
```
This is dead code since the Migration to 18.0 (974b492), when the
`messaging_service_patch.esm.js` was removed and replaced by a new
`mail_core_common_service_patch.esm.js`
…thod

The controller that called this method was removed during the Migration to 16.0,
OCA/social@ef73e2d

This method is a left-over, it's not used anywhere since.
There's already a collapsable panel for failed messages in the chatter.
Having this other panel is totally redundant, and it was a bit glitchy too.
Before this commit, when the user clicked on the icon of a message, the following error occurred:
ValueError: not enough values to unpack (expected 4, got 0)

Complementary to 86e188c
…s reviewed

Before these changes, when the bus event was received in tabs that did not have the message open, an error appeared because the system was not able to find the message.

After these changes, if the message is not available on the screen, the process continues because synchronization will not be necessary, and therefore the error will no longer occur.
Create a dedicated company alias domain during the test setup to avoid
temporary alias domains becoming referenced by aliases created by other
installed modules.

TT63167
Add optional mail headers expected by inherited `mail.thread`
implementations, avoiding failures when modules such as
`mass_mailing` are installed.

TT63167
Add the optional mail headers to the second payload as well to keep the
test compatible with inherited mail.thread implementations such as
mass_mailing.

TT63167
Currently translated at 100.0% (126 of 126 strings)

Translation: mail-19.0/mail-19.0-mail_tracking
Translate-URL: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_tracking/sl/
`MailMail._send()` tells a successful delivery from a failed one by the
exception raised by `send_email()`, not by its return value. `mail_tracking`
catches every exception and, when a `mail.tracking.email` record exists, records
the error on the tracking record and returns normally, so core believes the
mail was delivered: the recipient is marked as reached and its notification is
written `sent` for a mail that never left, core's `except AssertionError` never
runs so a NO_VALID_RECIPIENT is never classified, and the mail keeps the
placeholder failure reason set before the sending loop.

A tracking record is created for every outgoing email, so with `mail_tracking`
installed core's whole failure-handling path is disabled for the database.

This is not a duplicate of OCA#215/OCA#212, which added `else: raise`, i.e. it only
re-raises when there is NO tracking record -- the branch that is dead in
practice. The live case is the other one.

Re-raise unconditionally. The error is still recorded on the tracking record by
the `smtp_error()` call just above, so nothing is lost; only core's contract is
restored.

Note for adopters: delivery failures that used to be silent now surface as
`exception` states on `mail.mail`/`mail.notification`, so a backlog of
previously hidden failures may become visible at once on upgrade.

Fixes OCA#253
mail_id has an ON DELETE SET NULL foreign key to mail_mail, so every
deleted mail.mail scans the whole mail_tracking_email table. Odoo 19.0
deletes up to 10,000 cancelled mails per autovacuum run. With 7M
trackings that is about 1.5 s per mail without the index and 6.5 s for
the whole batch with it.

Use a partial index: mail_id is set to NULL every time its mail.mail is
deleted, so most rows hold NULL, and the foreign key trigger only runs
"WHERE mail_id = $1" with a non-NULL value. The index stays much
smaller, as core does for mailing.trace.mail_mail_id.
mail.message.mail_tracking_ids sets bypass_search_access, so the ORM
searches mail.tracking.email with bypass_access=True. _search ignored
it and filtered every matching tracking in Python. With 7M trackings,
get_failed_count went from 5-10 s to under 1 s.
res.users._init_messaging calls mail.message.get_failed_count, so every
web client load (/mail/data) searches is_failed_message. That search
filters on mail_tracking_needs_action, which has no index. Only a
handful of messages carry the flag, but PostgreSQL starts from the
failed trackings and probes mail_message by primary key once per
tracking. With 122M messages and 29k failed trackings the query took
152 s cold and 5 s warm.

Add a partial index on the flagged messages. It is tiny (584 kB on that
database), and a write only touches it when the flag changes.

The index is built once, by the first update after this change. Later
updates keep it, because Odoo only rebuilds an index whose definition
differs from the one stored in its comment. On a very large table that
build blocks writes (13 minutes on 122M messages), so INSTALL.md explains
how to create it beforehand with CREATE INDEX CONCURRENTLY and the
comment the ORM stores on it.
…tracking

Odoo 20.0 core provides a `mail_tracking` module (technical tracking
of field values), so this addon is renamed from `mail_tracking` to
`mail_recipient_tracking`.
@jarsabot

Copy link
Copy Markdown
    **WARNING**: Could not link to Odoo task. Record ID not found in the title of the MR, supported formats:
{ record type }#{ number }

Available types: 'task#', 't#' (case insensitive)

Examples:

  • task#123

  • i#123

@alan196
alan196 merged commit 9fa4374 into Jarsa:20.0 Nov 30, 2026
4 checks passed
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.