Friday, May 3, 2024
1 change · saas-17.2
Resolved issues and error corrections
Removing a follower with an invalid email address no longer causes an error. This keeps CRM lead follower management working smoothly even when user contact details are incomplete or malformed.
Original PR description
Currently, an error is generated when attempting to remove a user from followers who have an invalid email address. Step to produce: - Install the 'CRM' module without demo data. - Create a new user…
Currently, an error is generated when attempting to remove a user from followers who have an invalid email address.
Step to produce:
- Install the 'CRM' module without demo data.
- Create a new user 'Test' with the email 'test'
- Create a lead with 'Email' and salesperson 'Test'
- Click on the 'Show Followers' icon (top right corner), and remove 'Test' from Followers.
See Traceback:
```
KeyError: 'email'
File "odoo/http.py", line 2254, in __call__
response = request._serve_db()
File "odoo/http.py", line 1830, in _serve_db
return self._transactioning(_serve_ir_http, readonly=ro)
File "odoo/http.py", line 1850, in _transactioning
return service_model.retrying(func, env=self.env)
File "odoo/service/model.py", line 134, in retrying
result = func()
File "odoo/http.py", line 1828, in _serve_ir_http
return self._serve_ir_http(rule, args)
File "odoo/http.py", line 1835, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "odoo/http.py", line 2060, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "odoo/addons/base/models/ir_http.py", line 220, in _dispatch
result = endpoint(**request.params)
File "odoo/http.py", line 742, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "addons/mail/controllers/thread.py", line 16, in mail_thread_data
return thread._get_mail_thread_data(request_list)
File "home/odoo/src/enterprise/saas-17.2/whatsapp/models/mail_thread.py", line 9, in _get_mail_thread_data
res = super()._get_mail_thread_data(request_list)
File "addons/mail/models/mail_thread.py", line 4560, in _get_mail_thread_data
res['suggestedRecipients'] = self._message_get_suggested_recipients()
File "addons/crm/models/crm_lead.py", line 2007, in _message_get_suggested_recipients
self._message_add_suggested_recipient(
File "addons/mail/models/mail_thread.py", line 1836, in _message_add_suggested_recipient
if email and email in [val['email'] for val in result]: # already existing email -> skip
File "addons/mail/models/mail_thread.py", line 1836, in <listcomp>
if email and email in [val['email'] for val in result]: # already existing email -> skip
```
The issue occurs when removing user from followers. As a result the system encounter an error because it receives data without an 'email' key at [1].
link[1]: https://github.com/odoo/odoo/blob/5dd1fd84df78e3279c2a949d82199183ddec844a/addons/mail/models/mail_thread.py#L1836
To resolve the issue, use the get() method to retrieve a value from the data to prevent a key error and provide a default value as a False.
sentry-5238024403
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr