Tengo el codigo que genera un correo electronico utilizo el metodo mail.compose.message', funciona, envia el correo deseado a todos los detinatarios, pero cuando un destinatario quiere responder a todos los demas, no puede porque solo le deja responder al correo por default.
if record.x_studio_partner_id or record.x_studio_cliente:
template_id = 7 #Cambiar por el id de la plantilla correcta
current_user_email = record.env.user.email
attachment_ids = []
if record.x_studio_aceptacin_20:
attachment = record.env['ir.attachment'].create({
'name': record.x_studio_aceptacin_20_filename or 'Plan de Auditoría',
'datas': record.x_studio_aceptacin_20,
'res_model': 'x_auditoria',
'res_id': record.id,
})
attachment_ids = [(4, attachment.id)]
else:
raise UserError('Agregar Documento de Aceptación')
contactos_id = env['res.partner'].search([('category_id.name','in',['Planeación'])])
contactos_id2 = env['res.partner'].search([('email','=', record.env.user.email)])
auditores_id = [
auditor_id.id
for auditor_id in (
record.x_studio_auditor_lder,
record.x_studio_auditor,
record.x_studio_auditor_en_formacin
)
if auditor_id
]
partner_ids = [child.id for child in record.x_studio_cliente_desarrollo.child_ids if child.category_id.name in ['Contacto Principal']] + auditores_id + [contact2.id for contact2 in contactos_id2] + [contact.id for contact in contactos_id]
# Obtener los objetos partner (res.partner) a partir de los IDs
partners = model.env['res.partner'].browse(partner_ids)
# Extraer los correos electrónicos y unirlos en una cadena separada por comas
email_list = [partner.email for partner in partners if partner.email]
reply_to_emails = ','.join(email_list)
ctx = {
'default_model': 'x_auditoria',
'default_notify_author': True,
'default_notify_author_mention': True,
'default_notified_bcc': ([child.id for child in record.x_studio_cliente_desarrollo.child_ids if child.category_id.name in ['Contacto Principal']]+auditores_id+ [contact2.id for contact2 in contactos_id2]+ [contact.id for contact in contactos_id]),
'default_template_id': template_id,
'default_partner_ids': ([child.id for child in record.x_studio_cliente_desarrollo.child_ids if child.category_id.name in ['Contacto Principal']]+auditores_id+ [contact2.id for contact2 in contactos_id2]+ [contact.id for contact in contactos_id]),
'default_reply_to': reply_to_emails,
'default_subject': f'Plan de Auditoría // {record.x_studio_cliente_desarrollo.name}',
'default_res_ids': [record.id],
'default_email_from': current_user_email,
'default_attachment_ids': attachment_ids,
}
action = {
'type': 'ir.actions.act_window',
'view_mode': 'form,list',
'res_model': 'mail.compose.message',
'target': 'new',
'context': ctx,
'composition_mode':'comment',
}
record['x_studio_correo_enviado_7'] = True