Skip to content

[19.0][MIG] mail_gateway: Migration to 19.0#202

Open
DucTruongKomit wants to merge 66 commits into
OCA:19.0from
komit-consulting:19.0-mig-mail_gateway
Open

[19.0][MIG] mail_gateway: Migration to 19.0#202
DucTruongKomit wants to merge 66 commits into
OCA:19.0from
komit-consulting:19.0-mig-mail_gateway

Conversation

@DucTruongKomit

@DucTruongKomit DucTruongKomit commented Jun 1, 2026

Copy link
Copy Markdown

[MIG] mail_gateway: Migration to 19.0

olgamarcocb and others added 30 commits July 24, 2025 08:58
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.
…ging thread

Before these changes, the messages sent using the email thread were not being delivered.

After making these changes, since the gateway_notifications key is empty, the super is called and the process continues normally.
Signed-off-by pedrobaeza
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 2 times, most recently from 5e50ef4 to 7c9d8cc Compare June 1, 2026 11:17
@DucTruongKomit

Copy link
Copy Markdown
Author

Thanks for the move. I'm afraid you have lost the commit history. You should do a similar method than the migration one, but adding an extra remote for OCA/social.

yes, I did.

@pedrobaeza

Copy link
Copy Markdown
Member

Can you check CIs?

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 3 times, most recently from 0ec67ff to a649485 Compare June 2, 2026 01:31
@DucTruongKomit
DucTruongKomit marked this pull request as draft June 2, 2026 04:01
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 3 times, most recently from 56e4d37 to 6e924d8 Compare June 5, 2026 09:30

@huan-tq huan-tq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Functional Testing:

  • The Menus introduced by this module are available.
  • The Gateway buttons are available throughout the system.
  • This is a base module intended to be extended by other mail_gateway modules.

LGTM.

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 4 times, most recently from ec66121 to 1bcd4b7 Compare June 12, 2026 10:40
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch from 10c130b to e9d024f Compare June 26, 2026 10:48
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch from e9d024f to 33a1649 Compare June 26, 2026 10:57
@DucTruongKomit
DucTruongKomit marked this pull request as ready for review June 26, 2026 11:01
@DucTruongKomit

Copy link
Copy Markdown
Author

Can you check CIs?

It's ok now.

return res

@api.model
@tools.ormcache()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should add state and gateway_type

def _get_webhook_url(self):
return "{}/gateway/{}/{}/update".format(
self.webhook_url
or self.env["ir.config_parameter"].get_param("web.base.url"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add sudo().get_param

).bus_send()
return result

def _get_allowed_message_post_params(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

function is changed in v19 => _get_allowed_message_params

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

def _get_allowed_message_params(self):
    return super()._get_allowed_message_params() | {"gateway_notifications"}

return result
def _to_store(self, store: Store, fields):
res = super()._to_store(store, fields)
for record in self:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add filter self.filtered("gateway_id")

},
"gateway_name": record.gateway_id.name,
"gateway_id": record.gateway_id.id,
"gateway_name": record.name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

replace by "gateway": record.gateway_id._gateway_info(),

from odoo.addons.mail.tools.discuss import Store


class MailChannel(models.Model):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MailChannel -> DiscussChannel

Comment thread mail_gateway/security/security.xml Outdated
</record>
<record model="res.groups" id="gateway_user">
<field name="name">User</field>
<field name="category_id" ref="module_category_gateway" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should point to new Privilege

@api.depends("notification_ids", "gateway_message_ids")
def _compute_gateway_channel_ids(self):
for record in self:
if self.env.user.has_group("mail_gateway.gateway_user"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

move this out of for.

]

def _send_to_gateway_thread(self, gateway_channel_id):
chat_id = gateway_channel_id.gateway_id._get_channel_id(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if not chat_id => mail.gateway.abstract._get_channel(..., force_create=True)

@pedrobaeza pedrobaeza changed the title [MIG] mail_gateway: Migration to 19.0 [19.0][MIG] mail_gateway: Migration to 19.0 Jul 23, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration mail_gateway

Please incorporate #1839

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Jul 23, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Jul 23, 2026
35 tasks
follower_partners = (
self.env["mail.followers"]
.sudo()
.search([("res_id", "=", record.id), ("res_model", "=", record._name)])

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.

Should we use search_fetch for this ?

@Willysan2020

Copy link
Copy Markdown

Re the earlier comment about _get_allowed_message_params being renamed in v19 — the current code (mail_gateway/models/mail_thread.py) still overrides the old name:

def _get_allowed_message_post_params(self):
    result = super()._get_allowed_message_post_params()
    result.add("gateway_notifications")
    return result

Verified against an installed 19.0 core (mail/models/mail_thread.py): _get_allowed_message_post_params doesn't exist anymore, only _get_allowed_message_params does. So this override never runs, and gateway_notifications silently isn't recognized as an allowed message-post param.

Suggested fix:

def _get_allowed_message_params(self):
    result = super()._get_allowed_message_params()
    result.add("gateway_notifications")
    return result

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.