Hi everyone,
I'm facing a very specific issue in Odoo SaaS 19.1. I am trying to automate a WhatsApp template send from a Server Action.
The Problem: Even though I can trigger the send using action_send_whatsapp_template(), the message always arrives with "Sample Value" for all variables, ignoring the values I've tried to inject via Python.
What I've tried:
Creating the composer with with_context(active_model='crm.lead', active_ids=record.ids).
Updating variables after creation using composer.write({'wa_variable_ids': [(1, var_id, {'value': 'my_data'})]}).
The Server Action logs "Success", but the actual WhatsApp sent to the phone doesn't reflect the changes.
My code snippet:
Python
template = env['whatsapp.template'].search([('name', '=', 'my_template')], limit=1)
composer = env['whatsapp.composer'].with_context(active_model='crm.lead', active_ids=record.ids).create({
'res_model': 'crm.lead',
'res_ids': str(record.ids),
'wa_template_id': template.id
})
# Logic to update variables...
updates = [(1, var.id, {'value': 'Real Data'}) for var in composer.wa_variable_ids]
composer.write({'wa_variable_ids': updates})
# Triggering the send
composer.action_send_whatsapp_template()
My Question: In SaaS 19.1, is there a mandatory method to call (like a _compute or a specific flush) to ensure the wa_variable_ids are committed before action_send_whatsapp_template is executed? Or should I be using a different method to trigger the send that actually processes the composer's current state?