[14.0][FIX] crm: check if email_from is defined #1234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the issue/feature this PR addresses:
Facing a special case with both CRM and mail_tracking (from OCA social repo) installed.
When an opportunity or a lead was created from an incoming e-mail and then you remove the email_from on opportunity/lead (for instance because you have forwarded an email to Odoo to create opportunity but you do not want to keep your own email address as email_from for the lead), you get an error that boolean does not have lower() method.
This issue has been introduced with odoo@9ef715f part of odoo#74474
Since mail_tracking is trying to suggest extra emails, you get all message_ids.email_to as emails parameter when calling _message_partner_info_from_emails(emails) which it tries to compare with crm_lead.email_from
This PR fixes this issue by checking that email and self.email_from exist before trying to lower() them (as it was done before the above commit)
Current behavior before PR:
Stack trace when accessing lead / opportunity created from incoming e-mail where email_from has been emptied.
Desired behavior after PR is merged:
No more error, working correctly
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr