From f3fd9e5c6500c8f7b31807df871096b64242fa06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Tarroja=20Caubet?= Date: Sat, 6 Jun 2026 11:47:25 +0200 Subject: [PATCH] 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 (grafted from 868b0e31fbdecc0e04b2cb1c894829c5eba19fa4) --HG-- branch : 7.0 --- sao/src/window.js | 5 +++-- tryton/tryton/gui/window/email_.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sao/src/window.js b/sao/src/window.js index de5fb3c832..6f9718e408 100644 --- a/sao/src/window.js +++ b/sao/src/window.js @@ -2529,15 +2529,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 => { diff --git a/tryton/tryton/gui/window/email_.py b/tryton/tryton/gui/window/email_.py index abada7ce19..a1c0253e45 100644 --- a/tryton/tryton/gui/window/email_.py +++ b/tryton/tryton/gui/window/email_.py @@ -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', [])))