Use current record context when rendering email templates

Pass the current record context from the email dialog when fetching
template values and defaults. This keeps context-dependent models,
including table_query records, addressable after the user changes the
context.

Closes #14565
This commit is contained in:
Adrià Tarroja Caubet
2026-06-06 11:47:25 +02:00
parent 01b76919e4
commit 23a96d751d
2 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -2727,15 +2727,16 @@
},
_fill_with: function(template) {
var prm;
let context = this.record.get_context();
if (template) {
prm = Sao.rpc({
'method': 'model.ir.email.template.get',
'params': [template, this.record.id, {}],
'params': [template, this.record.id, context],
}, this.record.model.session);
} else {
prm = Sao.rpc({
'method': 'model.ir.email.template.get_default',
'params': [this.record.model.name, this.record.id, {}],
'params': [this.record.model.name, this.record.id, context],
}, this.record.model.session);
}
prm.then(values => {
+4 -2
View File
@@ -291,14 +291,16 @@ class Email(NoModal):
def _fill_with(self, template=None):
try:
context = self.record.get_context()
if template:
values = RPCExecute(
'model', 'ir.email.template', 'get',
template, self.record.id)
template, self.record.id, context=context)
else:
values = RPCExecute(
'model', 'ir.email.template', 'get_default',
self.record.model_name, self.record.id)
self.record.model_name, self.record.id,
context=context)
except RPCException:
return
self.to.set_text(', '.join(values.get('to', [])))