odoo/odoo#215315

Created by fw-bot
Merged at 179c31a6e22a59c35649fd108e29695045b81c5b

Statuses:

label
odoo-dev:master-18.0-opw-4839926-fix_scheduled_mail_attachment_upload-aksi-444365-fw
head
542e0ccc556fc8795a5626514ca5e4078d482eda
merged
7 months ago by Ajit Kumar Krishnanand Singh (aksi)
odoo/odoo
18.0 #212960
saas-18.1 #215260
saas-18.2 #215280
saas-18.3 #215304
saas-18.4
19.0
saas-19.1
master #215315

[FW][FIX] mail: prevent traceback on editing attachment of scheduled mail

Steps to reproduce
- open a record from Contacts app
- from chatter, click send mail , open full mail composer
- add a attachment
- schedule a message, by clicking '▼' on send message
- Again from chatter, click on edit the same message
- try to add another attachment

Observation:
A traceback is received

Issue:
Currently, onFileUploaded function attempts to get res_ids from data,
https://github.com/odoo/odoo/blob/69828835c926485ec80ed92e14dd11fbc6c1caaa/addons/mail/static/src/core/web/mail_composer_attachment_selector.js#L25-L30

but in case message is scheduled, which is stored in mail.scheduled.message ,when editing it we do not have res_ids
https://github.com/odoo/odoo/blob/69828835c926485ec80ed92e14dd11fbc6c1caaa/addons/mail/wizard/mail_compose_message.py#L120

instead we have res_id field,
https://github.com/odoo/odoo/blob/69828835c926485ec80ed92e14dd11fbc6c1caaa/addons/mail/models/mail_scheduled_message.py#L46
hence a traceback is received when trying to json parse a undefined value.

Fix:
Adapt the onFileUploaded function to consider both, res_ids and res_id

opw-4839926


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #212960