Skip to content

[18.0][FIX] mail_gateway: Fix channel member duplicates - #1883

Open
DevOpsMBAConsultings wants to merge 1 commit into
OCA:18.0from
DevOpsMBAConsultings:18.0-fix-channel-member-unique
Open

[18.0][FIX] mail_gateway: Fix channel member duplicates#1883
DevOpsMBAConsultings wants to merge 1 commit into
OCA:18.0from
DevOpsMBAConsultings:18.0-fix-channel-member-unique

Conversation

@DevOpsMBAConsultings

Copy link
Copy Markdown

Module: mail_gateway

When a webhook is received and the author (sender) happens to be one of the users already configured in gateway.member_ids, the previous logic resulted in the author's partner_id being appended to the members list even though it was already iterated over from gateway.member_ids.partner_id.

This caused Odoo's discuss.channel.create to fail with psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "discuss_channel_member_partner_id_channel_id_uniq".

Fix: Using a set for the member partner IDs and explicitly verifying that author.id not in member_pids before appending ensures partner_id is unique.

@pedrobaeza pedrobaeza changed the title [FIX] mail_gateway: Fix channel member duplicates [18.0][FIX] mail_gateway: Fix channel member duplicates Jul 9, 2026
@pedrobaeza
pedrobaeza requested a review from etobella July 9, 2026 13:40
@pedrobaeza pedrobaeza added this to the 18.0 milestone Jul 9, 2026
members.append(
Command.create(
{
"partner_id": author._name == "res.partner" and author.id,

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.

Why are you removing the part that checks the model?

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.

3 participants