-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
[17.0][MIG] mail_composer_cc_bcc: Migration to 17.0 #1312
[17.0][MIG] mail_composer_cc_bcc: Migration to 17.0 #1312
Conversation
a8827f8
to
b5b55df
Compare
ac57d71
to
1966425
Compare
Hello, Could you clarify why the module depends on the account? I couldn't find any justification for this dependency. Could you either remove it or explain the reasoning behind its inclusion? Thank you. |
Good catch @llabusch93 !
This will be fixed soon. |
1966425
to
f964a6a
Compare
Hi @llabusch93 and @nilshamerlinck, thank you for your review I updated as you suggested. |
672de7d
to
2772470
Compare
) | ||
else: | ||
# DIFFERENT FROM ODOO NATIVE: | ||
context = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is imperative. Instead of augmenting the context, it's being overwritten. This leads to unintended consequences in the sales module, such as orders not being flagged as sent upon sending the quote, due to the replacement of the context key that the sales module relies on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @llabusch93, I updated as you suggest 🙏
/ocabot migration mail_composer_cc_bcc |
dcbc48f
to
38027cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now.
self.move_ids, wizard.mail_template_id | ||
) | ||
wizard.partner_bcc_ids = self._get_default_mail_partner_bcc_ids( | ||
self.move_ids, wizard.mail_template_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.move_ids, wizard.mail_template_id | |
) | |
wizard.partner_bcc_ids = self._get_default_mail_partner_bcc_ids( | |
self.move_ids, wizard.mail_template_id | |
wizard.move_ids, wizard.mail_template_id | |
) | |
wizard.partner_bcc_ids = self._get_default_mail_partner_bcc_ids( | |
wizard.move_ids, wizard.mail_template_id |
you are iterating over possibly multiple wizards
def _get_default_mail_partner_cc_ids(self, move, mail_template): | ||
partners = self.env["res.partner"].with_company(move.company_id) | ||
if mail_template.email_cc: | ||
for mail_data in tools.email_split(mail_template.email_cc): | ||
partners |= partners.find_or_create(mail_data) | ||
return partners | ||
|
||
def _get_default_mail_partner_bcc_ids(self, move, mail_template): | ||
partners = self.env["res.partner"].with_company(move.company_id) | ||
if mail_template.email_bcc: | ||
for mail_data in tools.email_split(mail_template.email_bcc): | ||
partners |= partners.find_or_create(mail_data) | ||
return partners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're almost doing twice the same thing here. Would it be possible to factorize this code ?
Also, building a new recordset of partners from a set of partner ids with browse
is more efficient than appending records multiple times.
new_message = move.with_context( | ||
no_new_invoice=True, | ||
mail_notify_author=self.env.user.partner_id.id in partner_ids, | ||
is_from_composer=True, | ||
partner_cc_ids=self.partner_cc_ids, | ||
partner_bcc_ids=self.partner_bcc_ids, | ||
).message_post( | ||
message_type="comment", | ||
**kwargs, | ||
**{ | ||
"email_layout_xmlid": "mail.mail_notification_layout_with_responsible_signature", # noqa: E501 | ||
"email_add_signature": not mail_template, | ||
"mail_auto_delete": mail_template.auto_delete, | ||
"mail_server_id": mail_template.mail_server_id.id, | ||
"reply_to_force_new": False, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not blocking, but I would prefer having this in more steps.
new_message = move.with_context( | |
no_new_invoice=True, | |
mail_notify_author=self.env.user.partner_id.id in partner_ids, | |
is_from_composer=True, | |
partner_cc_ids=self.partner_cc_ids, | |
partner_bcc_ids=self.partner_bcc_ids, | |
).message_post( | |
message_type="comment", | |
**kwargs, | |
**{ | |
"email_layout_xmlid": "mail.mail_notification_layout_with_responsible_signature", # noqa: E501 | |
"email_add_signature": not mail_template, | |
"mail_auto_delete": mail_template.auto_delete, | |
"mail_server_id": mail_template.mail_server_id.id, | |
"reply_to_force_new": False, | |
}, | |
) | |
move_with_context = move.with_context( | |
no_new_invoice=True, | |
mail_notify_author=self.env.user.partner_id.id in partner_ids, | |
is_from_composer=True, | |
partner_cc_ids=self.partner_cc_ids, | |
partner_bcc_ids=self.partner_bcc_ids, | |
) | |
extra_args = { | |
"email_layout_xmlid": "mail.mail_notification_layout_with_responsible_signature", | |
"email_add_signature": not mail_template, | |
"mail_auto_delete": mail_template.auto_delete, | |
"mail_server_id": mail_template.mail_server_id.id, | |
"reply_to_force_new": False, | |
"message_type": "comment" | |
} | |
kwargs.update(extra_args) | |
move_with_context.message_post(**kwargs) |
@trisdoan can you check @mmequignon's comments? |
d102f75
to
f9826d2
Compare
Hello @mmequignon, @gurneyalex I took your suggestions into account 🙏 |
Hello @mmequignon's , how does it look to you? |
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/
f9826d2
to
217a993
Compare
Hello @gurneyalex, could you please remerge |
/ocabot merge nobump |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 8270ee8. Thanks a lot for contributing to OCA. ❤️ |
1) Summary of changes in 17.0
mail.template
https://github.com/odoo/odoo/blob/17.0/addons/mail/models/mail_template.py
generate_recipients
replaced by_generate_template_recipients
mail.mail:
https://github.com/odoo/odoo/blob/17.0/addons/mail/models/mail_mail.py
_prepare_outgoing_list
: odoo/odoo@b1d678b_send_prepare_values
_personalize_outgoing_body
is also introducedaccount.move.send: replaces account_invoice_send
_action_send_mail
replaced by_send_mail
_get_mail_move_values
2) Consequences
_get_mail_move_values
and_send_mail
in account.move.send as it does not benefit from mail.compose.message3) This change
mail_tracking
)test_MailTemplate_upstream_file_hash
&test_MailComposer_upstream_file_hash
to keep track of changes upstream_compute_partner_ids
_action_send_mail
update context when composition_mode == 'comment'
My colleague Hai is busy on other topics, I will take over as a maintainer of this module from now on.