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:
+3
-2
@@ -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 => {
|
||||
|
||||
@@ -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', [])))
|
||||
|
||||
Reference in New Issue
Block a user