[FIX] google_calendar: avoid browse(False) instead of void records
If no partner is found for a given email after calling '_mail_search_on_user' and '_mail_find_partner_from_emails' the returned result is a void recordset for the email. When rebrowsing partners afterwards, browsing p.id for each partner leads to potentially browsing False, which gives a different recordset from a void recordset. This further causes a crash in '_write_from_google' as he considers [False] as not being void. This commit fixes that by correctly filtering out void partners. This is globally a followup of odoo/odoo#99330. Task-3453577 (TestMail: Update Alias/Gateway tests for MC) Prepares Task-36879 (Mail: Support MultiCompany Aliases) Part-of: odoo/odoo#130768
This commit is contained in:
@@ -310,7 +310,7 @@ class GoogleSync(models.AbstractModel):
|
||||
email not in [partner.email_normalized for partner in partners]]
|
||||
if remaining:
|
||||
partners += self.env['mail.thread']._mail_find_partner_from_emails(remaining, records=self, force_create=True)
|
||||
unsorted_partners = self.env['res.partner'].browse([p.id for p in partners])
|
||||
unsorted_partners = self.env['res.partner'].browse([p.id for p in partners if p.id])
|
||||
# partners needs to be sorted according to the emails order provided by google
|
||||
k = {value: idx for idx, value in enumerate(emails)}
|
||||
result = unsorted_partners.sorted(key=lambda p: k.get(p.email_normalized, -1))
|
||||
|
||||
Reference in New Issue
Block a user