Skip to content

[20.0][MIG] mail_gateway: Migration to 20.0 - #314

Merged
OCA-git-bot merged 62 commits into
OCA:20.0from
Tecnativa:20.0-MIG-mail_gateway
Nov 20, 2026
Merged

OCA-git-bot merged 62 commits into
OCA:20.0from
Tecnativa:20.0-MIG-mail_gateway

Conversation

@CarlosRoca13

Copy link
Copy Markdown

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration mail_gateway

@OCA-git-bot OCA-git-bot added this to the 20.0 milestone Oct 23, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Oct 23, 2026
2 of 25 tasks
@etobella

Copy link
Copy Markdown
Member

include this comits 🙏
OCA/social#1937

@CarlosRoca13

Copy link
Copy Markdown
Author

Done @etobella

@CarlosRoca13
CarlosRoca13 force-pushed the 20.0-MIG-mail_gateway branch 2 times, most recently from 892eb44 to bcb1bad Compare October 26, 2026 14:58
@carlos-lopez-tecnativa

Copy link
Copy Markdown
Contributor

Please include #324

@pedrobaeza

Copy link
Copy Markdown
Member

@carlos-lopez-tecnativa can you put up to date this PR including #353 and #324?

olgamarcocb and others added 19 commits November 18, 2026 12:05
Currently translated at 100.0% (85 of 85 strings)

Translation: social-16.0/social-16.0-mail_gateway
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_gateway/it/
Other OCA modules extending the composer add m2m fields with fixed
relations. To avoid a glue module we try for the moment to add those
manually.

TT51108
Currently translated at 81.2% (113 of 139 strings)

Translation: social-16.0/social-16.0-mail_gateway
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_gateway/it/
Currently translated at 10.7% (15 of 139 strings)

Translation: social-16.0/social-16.0-mail_gateway
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_gateway/es/
…ated to the current user

- Use OdooBot for webhooks instead of the current user, following the same logic as Odoo.
- Avoid automatically adding the current user as a member of a new gateway to prevent notifications for all messages. This is now an explicit configuration.
Adridot and others added 17 commits November 18, 2026 12:07
Odoo 18 renamed the Thread record field `lastInterestDateTime` to
`lastInterestDt` (defined in mail/static/src/core/common/thread_model.js;
used by the "chats" category sort in
mail/static/src/core/public_web/discuss_app_category_model.js).

The 17.0 patch was ported unchanged, so `compareDatetime()` compares
`undefined` with `undefined` and silently falls back to `t2.id - t1.id`:
gateway channels end up stacked by creation order instead of last
activity.

Use the 18.0 field name so the gateway category is sorted by last
interest again, most recent first.
The patch on Store.one_id is applied at import time, so it is shared by
every registry served by the process, while gateway_channel_ids only
exists in the registries where mail_gateway is installed. A database
without the module, served by a worker that already imported it, fails
with an AttributeError inside session_info(), which leaves its whole
backend unreachable.

Check the registry the call actually runs against before reading the
field.
…ll a member

Otherwise, bus notifications keep arriving after leaving the channel, and an AccessError is raised because the user is no longer a member.
…ateway_user security group

The members in the gateway are used to set the default members for new channels. However, in day-to-day use, if new users are added to the mail_gateway.gateway_user group, they do not automatically become members of existing channels.

With the native option to invite people, new users can join the channel. However, for security reasons, we limit this to users who belong to the mail_gateway.gateway_user group.

Core has a feature that uses the group_public_id field to set a group that restricts which users can be invited. However, this only works when channel_type = 'channel'. See https://github.com/odoo/odoo/blob/5249e0b082cfff650e1dad36aade470cf25a1ad5/addons/mail/models/discuss/discuss_channel.py#L90
Store.one_id() builds the reference to a record rather than its content,
and its docstring asks callers to avoid it. Sending the gateway channels
from a res.partner._to_store() override instead, the way hr_holidays and
im_livechat extend partner store data, removes the need for the registry
guard added in #1913: a model override only exists in the registries
where its module is installed.

_thread_to_store() read the channels back from the follower references
and passed them on as gateway_followers without ever adding the partners
to the store, so it relates them with Store.many() now.
The conditions of the "New Partner" and "Open Contact" thread actions
started an async searchRead and then re-rendered the owner. Conditions are
evaluated on every render, so this re-rendered DiscussContent while it was
still mounting and the Owl fiber never completed: Discuss showed no
messages in any channel.

The gateway partner and the single guest of the channel are now sent with
the channel store data, and the conditions only read them.

Fixes OCA#319

Assisted-by: Claude Opus 5.5
_to_store runs for every channel of the user on Discuss load: search
res.partner.gateway.channel once for the whole recordset instead of once
per gateway channel.
stateToUrl is not exported by @web/core/browser/router in 19.0 (only
through the router object), so building the URL of a gateway message
failed as soon as such a message was rendered. It went unnoticed while
Discuss did not render any message.
…tions

mail.gateway is readable only by administrators since 0fd2edc, so a
gateway user that is not an administrator got an AccessError when the
conversation was sent to the client (discuss.channel._to_store), when
posting in it and when leaving it. Read the gateway with sudo there:
only its id, name and type are used.
The mail.resend.message wizard no longer exists in 19.0, so the user only
saw "Exception" when a gateway message failed. Send a short version of
failure_reason with gateway notifications and show it in the message
notification popover instead.
Gateway users without administration rights got an AccessError when sending a message with the 'Send with gateway' wizard, merging a guest into a contact or loading the models of the 'Link to thread' wizard, as mail.gateway is only readable by administrators.
("gateway") is a string, not a tuple, so 'not in' checked for a substring of 'gateway' instead of the gateway channel type.
@carlos-lopez-tecnativa

Copy link
Copy Markdown
Contributor

@carlos-lopez-tecnativa can you put up to date this PR including #353 and #324?

Done. Additionally, I found some access errors caused by OCA/social#1937, so I backported f8ec84d to earlier versions.

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested with #320

@pedrobaeza pedrobaeza left a comment

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.

Code review

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 20.0-ocabot-merge-pr-314-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 26f0944 into OCA:20.0 Nov 20, 2026
8 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at f8c70a4. Thanks a lot for contributing to OCA. ❤️

@pedrobaeza
pedrobaeza deleted the 20.0-MIG-mail_gateway branch November 20, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.