Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Email Templatproblem: Email sent doesn't go out

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
developmentmail
3 Odpowiedzi
1403 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Georg Zurhelle
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
D Enterprise
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
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
Awatar
Awatar
1
paź 25
1115
Button without odoo access via Email Template
action development mail
Awatar
Awatar
1
wrz 25
818
Email Domain Warm Up... Rozwiązane
development message mail
Awatar
Awatar
1
sie 25
1021
Where is the function that send notification when their are some object's activity?
development follower mail
Awatar
1
mar 15
6853
How to make all branches for user active automatically after login his account?
development
Awatar
Awatar
1
lis 25
169
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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