Skip to content

Commit

Permalink
[FIX] mail_show_follower: Use company from the document to render mes…
Browse files Browse the repository at this point in the history
…sages correctly + proper lang handle

In a multi-company environment, if one company uses the
show_followers_partner_format by partner_name and another company
uses partner_email, a user with permissions in both companies may
experience issues. If a document belongs to Company A, but the current
company is set to Company B, the message format is taken from the
current company (Company B) instead of the document’s company
(Company A). This fix ensures that the message format is rendered based
on the document's company.

It also fixes the lang handling for cases with False values.
  • Loading branch information
carlos-lopez-tecnativa authored and pedrobaeza committed Oct 11, 2024
1 parent 3eeb62c commit 1de314a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 7 additions & 5 deletions mail_show_follower/models/mail_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):
show_in_cc_recipients = recipients._filter_shown_in_cc(show_internal_users)
if len(show_in_cc_recipients) <= 1:
continue

langs = (
mail.notification_ids.res_partner_id.mapped("lang")
lang = (

Check warning on line 75 in mail_show_follower/models/mail_mail.py

View check run for this annotation

Codecov / codecov/patch

mail_show_follower/models/mail_mail.py#L75

Added line #L75 was not covered by tests
mail.notification_ids.res_partner_id[:1].lang
or mail.author_id.lang
or company.partner_id.lang
or "en_US"
)
final_cc = mail.with_context(lang=langs[0])._build_cc_text(
show_in_cc_recipients
final_cc = (

Check warning on line 81 in mail_show_follower/models/mail_mail.py

View check run for this annotation

Codecov / codecov/patch

mail_show_follower/models/mail_mail.py#L81

Added line #L81 was not covered by tests
mail.with_context(lang=lang)
.with_company(company)
._build_cc_text(show_in_cc_recipients)
)
mail.body_html = final_cc + mail.body_html

Check warning on line 86 in mail_show_follower/models/mail_mail.py

View check run for this annotation

Codecov / codecov/patch

mail_show_follower/models/mail_mail.py#L86

Added line #L86 was not covered by tests
return super()._send(
Expand Down
11 changes: 4 additions & 7 deletions mail_show_follower/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -437,9 +436,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down

0 comments on commit 1de314a

Please sign in to comment.