Skip to content

[15.0][ADD] mail_partner_company_resolve#944

Open
nobuQuartile wants to merge 1 commit intoOCA:15.0from
qrtl:15.0-add-mail_partner_company_resolve
Open

[15.0][ADD] mail_partner_company_resolve#944
nobuQuartile wants to merge 1 commit intoOCA:15.0from
qrtl:15.0-add-mail_partner_company_resolve

Conversation

@nobuQuartile
Copy link

In models like project.task that interact directly with customers, incoming emails add CC addresses as followers, but the company restriction is not considered.
In a multi-company environment, if a customer sends an email with a CC address that belongs to a contact dedicated to another company, that contact is added as a follower.
Since the user lacks access rights to that contact’s company, they can no longer view the chatter.

This module addresses the issue by adding a company domain when matching email addresses to contacts.
If no contact visible to that company is found, a new contact is created and that company is set on the company field.

@qrtl
QT6388

@nobuQuartile nobuQuartile marked this pull request as draft February 13, 2026 08:34
@nobuQuartile nobuQuartile force-pushed the 15.0-add-mail_partner_company_resolve branch from 4150772 to 664ff17 Compare February 17, 2026 06:52
@nobuQuartile nobuQuartile marked this pull request as ready for review February 17, 2026 06:53
@nobuQuartile nobuQuartile changed the title [ADD] mail_partner_company_resolve [15.0][ADD] mail_partner_company_resolve Feb 17, 2026
@@ -0,0 +1,10 @@

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

CC addresses as followers, but the company restriction is not considered. In a multi-company
environment, if a customer sends an email with a CC address that belongs to a contact
dedicated to another company, that contact is added as a follower. Since the user lacks
access rights to that contact’s company, they can no longer view the chatter.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
access rights to that contact’s company, they can no longer view the chatter.
access rights to that contact’s company, they get an access error viewing the record.

Comment on lines +2 to +3
(or no company) and ensures new partners created from emails are assigned to the
current company.
Copy link
Member

Choose a reason for hiding this comment

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

and ensures new partners created from emails are assigned to the current company.

Do we need this functionality?

Comment on lines +13 to +15
if not extra_domain:
extra_domain = []
extra_domain.append(("company_id", "in", [self.env.company.id, False]))
Copy link
Member

Choose a reason for hiding this comment

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

To be safe.

Suggested change
if not extra_domain:
extra_domain = []
extra_domain.append(("company_id", "in", [self.env.company.id, False]))
extra_domain = expression.AND(
[extra_domain or [], [("company_id", "in", [self.env.company.id, False])]]
)

Comment on lines +16 to +27
threads_with_default_company = self.with_context(
default_company_id=self.env.company.id
)
partners = super(
MailThread, threads_with_default_company
)._mail_find_partner_from_emails(
emails,
records=records,
force_create=force_create,
extra_domain=extra_domain,
)
return partners
Copy link
Member

Choose a reason for hiding this comment

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

Assigning the default company can be handled with https://github.com/OCA/partner-contact/tree/15.0/partner_company_default IMO. Any reason we should force it here?

Suggested change
threads_with_default_company = self.with_context(
default_company_id=self.env.company.id
)
partners = super(
MailThread, threads_with_default_company
)._mail_find_partner_from_emails(
emails,
records=records,
force_create=force_create,
extra_domain=extra_domain,
)
return partners
return super()._mail_find_partner_from_emails(
emails,
records=records,
force_create=force_create,
extra_domain=extra_domain,
)

@yostashiro
Copy link
Member

Name suggestion: mail_partner_resolution_by_company (which is actually the name in the manifest file).

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.

2 participants

Comments