odoo/odoo#252499

Created by fw-bot
Merged at e2b0fefaf9e7ee3fdadfa159be78fd66c9ac098b

Statuses:

label
odoo-dev:master-saas-18.4-opw-5980079-send_email_on_candidate_refusal-mdek-505132-fw
head
76b60baf0306ef611ae42dffaed1c895ca9d60a4
merged
3 months ago by Maeva de Keyser (mdek)
odoo/odoo
saas-18.4 #252036
19.0 #252255
saas-19.1 #252312
saas-19.2 #252334
saas-19.3
master #252499

[FIX] hr_recruitment: send mail when candidate is refused

Short functional explanation of the error

When a candidate is refused, an email isn't sent to their email address.

Reproduction Steps

  1. Open Mailhog in a separate tab.
  2. Go to the Recruitment app and select any job position.
  3. Click on new to create a new application. Enter an applicant name and an applicant email.
  4. Check Mailhog: a job application has been sent to the applicant.
  5. Go back on the Recruitment app and click on Refuse. In the wizard, make sure you toggle Send Email and click on Refuse.

Expected behavior

In Mailhog, a refusal mail has been sent to the applicant.

Unexpected behavior

Nothing is sent.

Origin of the issue

When refusing a candidate, we create a notification in the chatter but an email isn't sent. This is due to the incoming_email_to field, which is checked here:

https://github.com/odoo/odoo/blob/bfc1c210eca65de1116aa09cdd62749ed9192407/addons/mail/models/mail_thread.py#L4040-L4053

but because this field is already retrieved here:
https://github.com/odoo/odoo/blob/bfc1c210eca65de1116aa09cdd62749ed9192407/addons/mail/models/mail_thread.py#L4025 the last condition will always be true, preventing the recipient's data to be added to the message, thus preventing the message to be sent correctly.

Note: as of 19.0, the field outgoing_email_to can be used to determine the recipient's email address.
Note: we remove 'body_is_html': True because this field
is misused in this case: when set at true, the field is always
considered as HTML
__
opw-5980079

Forward-Port-Of: #252334
Forward-Port-Of: #252036