Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Email Templatproblem: Email sent doesn't go out

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
developmentmail
3 Respuestas
1406 Vistas
Avatar
Georg Zurhelle

Hello Guys,

Im running Odoo.sh on version 18.

I createt a record of a template with following entrys. It gets called from a other module an through a comand with context. Some how the mail_to field doesnt get updatet. 

Can some help me wtih this?

If I use the comment field everything works.

email_adress = "test@dummy.com"

template = self.env.ref("reminder_activity_cron.email_template_remindermail_aktivity")

template = template.with_context(user=f"{email_adress}", displayname = displayname, resName = resName, link= link).send_mail(self.id, force_send=True)

<odoo>

    <data noupdate="0">

        <record id="email_template_remindermail_aktivity" model="mail.template">

            <field name="name">Remindermail aktivity</field>

            <field name="model_id" ref="mail.model_mail_activity"/>

            <field name="subject">Reminder Task due Today</field>

            <field name="email_from">reminder@reminder.com</field>

            <field name="description">Rindermail for Task due Today</field>

        <!--<field name="email_to">bot@bot.com</field>-->

            <field name="email_to">{{user}}</field>

            <field name="body_html" type="html">

<!-- Body is a littel bit longer but is working-->

​ ​ ​</field>

        </record>

    </data>

</odoo>

0
Avatar
Descartar
Avatar
Georg Zurhelle
Autor Mejor respuesta

Hi,

 the solution from  Desk Enterprise worked for me. 

After a bit of testing the ctx.get() funktion ist the way to go.

Thank you for the help.

<field name="email_to">{{ ctx.get('user', '') }}</field>

0
Avatar
Descartar
Avatar
D Enterprise
Mejor respuesta

Hii,

{{user}} Jinja variable doesn't automatically pick up the context value unless you reference it explicitly as ctx['user'] in the template.

Because when Odoo renders email templates, it uses ctx to refer to the rendering context passed from with_context().

so please try below code 
<record id="email_template_remindermail_aktivity" model="mail.template">

    <field name="name">Remindermail aktivity</field>

    <field name="model_id" ref="mail.model_mail_activity"/>

    <field name="subject">Reminder Task due Today</field>

    <field name="email_from">reminder@reminder.com</field>

    <field name="description">Reminder mail for Task due Today</field>

    <field name="email_to">{{ ctx.get('user', '') }}</field>

    <field name="body_html" type="html">

        <!-- Body is a littel bit longer but is working-->

    </field>

</record>


i hope it is usefull



0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,


The problem is related to how the context variables are passed and rendered in the mail.template. The email_to field in the template expects a valid Jinja expression, and you're passing {{ user }} which is correct syntax only if the context is set up correctly.


In your code, you're using user=f"{email_adress}", but this should be passed as user in the rendering context, not just the environment context.


Try with the following code.


email_address = "test@dummy.com"


template = self.env.ref("reminder_activity_cron.email_template_remindermail_aktivity")


template = template.with_context(

    email_to=email_address,

    displayname=displayname,

    resName=resName,

    link=link

).send_mail(self.id, force_send=True)


Then in your XML template, update email_to field like:


<field name="email_to">{{ email_to }}</field>


Use context keys that match your Jinja variable names. So if you write {{ email_to }} in the template, then pass email_to in context. Always ensure that force_send=True is used if you want the email sent immediately.


Hope it helps

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Crear envio de correo con accion de servidor y widget mail.compose.message, pero requiero agregar correos para destinatarios y responder a todos ellos.
development mail
Avatar
Avatar
1
oct 25
1117
Button without odoo access via Email Template
action development mail
Avatar
Avatar
1
sept 25
819
Email Domain Warm Up... Resuelto
development message mail
Avatar
Avatar
1
ago 25
1021
Where is the function that send notification when their are some object's activity?
development follower mail
Avatar
1
mar 15
6856
How to make all branches for user active automatically after login his account?
development
Avatar
Avatar
1
nov 25
175
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now