Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] mail_composer_cc_bcc: Migration to 18.0 #3

Open
wants to merge 30 commits into
base: 18.0
Choose a base branch
from

Conversation

trisdoan
Copy link
Contributor

@trisdoan trisdoan commented Nov 12, 2024

Changes in 18.0

  • uid was forced in odoo/odoo@9bc32a3, which made some keys are missing compared to standard '_notify_get_recipients'

This changes

[IMP] mail_composer_cc_bcc: refactor _generate_template_recipients

  • Took this chance to refactor this long method
    • It was completely overridden in previous migration, which is not necessary
    • Also, it results in Invalid field 'partner_bcc_ids' on model 'mail.mail in case of mass mailing

def _prepare_email_message(self, message, smtp_session):
"""
Define smtp_to based on context instead of To+Cc+Bcc
"""
Copy link

Choose a reason for hiding this comment

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

If i choose to add no default user inside Bcc (from company). But then i add them manually within the composer, i got this error: Invalid email address. It is because of the native _prepare_email_message which checks if email address is inside 'email_to', 'email_cc', 'email_bcc'. However, Bcc addresses is empty (inside the headers instead). So smtp_to_list is empty too and the assert smtp_to_list, self.NO_VALID_RECIPIENT returns the error.

I tested with Odoo 17.4 which is not 18 but closely, and i was able to bypass the error by adding my Bcc addresses list inside the message before calling super().

# Find the value for 'X-Odoo-Bcc'
x_odoo_bcc_value = next((value for key, value in message._headers if key == 'X-Odoo-Bcc'), None)
# Add Bcc field inside message to pass validation
if x_odoo_bcc_value:
    message['Bcc'] = x_odoo_bcc_value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Jerem-b, indeed, thank you so much 🙏

I just updated the code to include your contribution

hailangvn and others added 26 commits December 16, 2024 08:54
Currently translated at 83.3% (15 of 18 strings)

Translation: social-16.0/social-16.0-mail_composer_cc_bcc
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_composer_cc_bcc/es/
Currently translated at 100.0% (18 of 18 strings)

Translation: social-16.0/social-16.0-mail_composer_cc_bcc
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_composer_cc_bcc/es/
Currently translated at 100.0% (18 of 18 strings)

Translation: social-16.0/social-16.0-mail_composer_cc_bcc
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_composer_cc_bcc/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: social-17.0/social-17.0-mail_composer_cc_bcc
Translate-URL: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_composer_cc_bcc/
Currently translated at 100.0% (17 of 17 strings)

Translation: social-17.0/social-17.0-mail_composer_cc_bcc
Translate-URL: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_composer_cc_bcc/it/
…onstraint "unique_mail_message_id_res_partner_id_if_set" when adding the same user to CC field that is already set as a follower
@trisdoan trisdoan force-pushed the 18.0-mig-mail_composer_cc_bcc branch from 3b65220 to 905eb25 Compare December 16, 2024 09:22
@hbrunn
Copy link
Member

hbrunn commented Dec 18, 2024

no time for reviewing this right now, but it would make sense to add a commit here to make you the maintainer here too I think

ignore, you did so already in v17

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.