Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Email template in custom module - passing data

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
emailcustomtemplateodoo
7 Antwoorden
17079 Weergaven
Avatar
Dr Obx

Hi guys, how can I do it ?

My template contains:


<openerp>

<data noupdate="1">

<record id="stock_check_form" model="email.template">

<field name="name">Order form</field>

<field name="email_from">odoo@rs.com</field>

<field name="subject">Order</field>

<field name="model_id" ref="stock.check"/>

<field name="email_to" >rob@com.com</field>

<field name="partner_to"></field>

<field name="auto_delete" eval="False"/>

<field name="body_html">

<![CDATA[

<style>

span.oe_mail_footer_access {

display:block;

text-align:center;

color:grey;

}

</style>

<div style="border-radius: 2px; max-width: 800px; height: auto;margin-left: auto;margin-right: auto;background-color:#f9f9f9;">

<div style="height: auto;margin-left:12px;margin-top:30px;">

<p>U R G E N T !</p>

</div>

</div>

]]>

</field>

</record>

</data>

</openerp>

If I put data directly into template it look  like

tags only even if data in html_body field are formatted like that:

== email >>>>>=========================

[(0, 0, {'eelms': 132.0, 'eeqty_required': 90.0, 'eeproduct_id': 3, 'eemail_id': 39, 'eeproduct_qty': 85.0, 'eecurrent_stock': 0, 'eemwosres': 14}), (0, 0, {'eelms': 8.0, 'eeqty_required': 5.0, 'eeproduct_id': 18, 'eemail_id': 39, 'eeproduct_qty': 6.0, 'eecurrent_stock': 1, 'eemwosres': 1}), (0, 0, {'eelms': 14.0, 'eeqty_required': 8.0, 'eeproduct_id': 300, 'eemail_id': 39, 'eeproduct_qty': 13.0, 'eecurrent_stock': 1, 'eemwosres': 2}), (0, 0, {'eelms': 42.0, 'eeqty_required': 30.0, 'eeproduct_id': 909, 'eemail_id': 39, 'eeproduct_qty': 25.0, 'eecurrent_stock': 3, 'eemwosres': 4}), (0, 0, {'eelms': 39.0, 'eeqty_required': 27.0, 'eeproduct_id': 1214, 'eemail_id': 39, 'eeproduct_qty': 24.0, 'eecurrent_stock': 1, 'eemwosres': 4})]

== body >>>>>>=================================

[<tr><td><b>0</b></td><td>0</td><td>{""eelms"":132.0""eeqty_required"":90.0""eeproduct_id"":3""eemail_id"":39""eeproduct_qty"":85.0""eecurrent_stock"":0""eemwosres"":14}</td></tr><tr><td><b>0</b></td><td>0</td><td>{""eelms"":8.0""eeqty_required"":5.0""eeproduct_id"":18""eemail_id"":39""eeproduct_qty"":6.0""eecurrent_stock"":1""eemwosres"":1}</td></tr><tr><td><b>0</b></td><td>0</td><td>{""eelms"":14.0""eeqty_required"":8.0""eeproduct_id"":300""eemail_id"":39""eeproduct_qty"":13.0""eecurrent_stock"":1""eemwosres"":2}</td></tr><tr><td><b>0</b></td><td>0</td><td>{""eelms"":42.0""eeqty_required"":30.0""eeproduct_id"":909""eemail_id"":39""eeproduct_qty"":25.0""eecurrent_stock"":3""eemwosres"":4}</td></tr><tr><td><b>0</b></td><td>0</td><td>{""eelms"":39.0""eeqty_required"":27.0""eeproduct_id"":1214""eemail_id"":39""eeproduct_qty"":24.0""eecurrent_stock"":1""eemwosres"":4}</td></tr>]

Don't know how to ..... ;(

Why I'm getting this:  [<tr><td><b>0</b></td><td>0</td><td>{""eelms"":132.0""eeqty_required"":90.0""eeproduct_id"":3""eemail_id"":39""eeproduct_qty"":85.0""eecurrent_stock"":0""eemwosres"":14}

instead of:

  [<tr><td><b>eelms:132.0 </b></td><td>eeqty_required:90.0 </td><td>.....]

or

  [<tr><td><b>132.0 </b></td><td>90.0 </td><td>.....]  

?

0
Avatar
Annuleer
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Beste antwoord

Hi Dr Obx,

Create a new XML file and add it to the __openerp__.py file as dependency. An example of such a template:

<openerp>
<data noupdate="1">
<record id="your_template_email" model="mail.template">
<field name="name">Template title</field>
<field name="email_from">${object.event_id.user_id.email or ''}</field>
<field name="subject">${object.event_id.name} - Reminder</field>
<field name="model_id" ref="calendar.model_calendar_attendee"/>
<field name="email_to" >${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)}</field>
<field name="partner_to">${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False }</field>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<style>
span.oe_mail_footer_access {
display:block;
text-align:center;
color:grey;
}
</style>
<div style="border-radius: 2px; max-width: 1200px; height: auto;margin-left: auto;margin-right: auto;background-color:#f9f9f9;">
<div style="height: auto;margin-left:12px;margin-top:30px;">
<p>ANY TEXT YOU WANT HERE!</p>
</div>
</div>
]]>
</field>
</record>
</data>
</openerp>


As you can see you can add CSS etc in it. An important note is to add data noupdate="1" in it though! So the template is never reloaded.

Yenthe

1
Avatar
Annuleer
Dr Obx
Auteur

Thank you Yanthe, If I can ask you one more question, how can I populate a table in email with data from the list I created ? For example: as a result of my mtehod I'm getting this:

email.append((0, 0, {'eproduct_id': rec[0],'eproduct_qty':rec[1],'emwosres':mwosres,'elms': lms, 'eqty_required':qtyreq,'ecurrent_stock': int(rec[2])}))
Inside this list is for example 5 products and I would like to put them in table straight into email .... how can I do it ?
Mario Gielissen

@Yenthe How to include the xml file in __init__.py? Normally in __openerp__.py with 'data' : ['xx.xml'],?

Yenthe Van Ginneken (Mainframe Monkey)

@Mario my bad, I did mean the __openerp__.py file, I corrected my answer. :)

Avatar
Pawan
Beste antwoord

Rob,

to loop throught the data which is not in current object, you can do that in python only, and send it to the template body...

you can get string of all the product details like this:

for lists in YOUR_DICTIONARY:

product_desc += """

<tr>

<td><b>%s</b></td>

<td> %s</td>

<td> %s</td>

.............[more_data]

</tr>

""" % (list['eproduct_id'], list['eproduct_qty'], list['emwosres']..........[more_data_reference])

then append it to the body
body = """

Hi,</br>

Please find Product details below:</br>

  <b><u>Product Details</u></b>: </br>

  <p>%s</p>

""" % (product_desc)

IF YOU DIRECTLY WANT TO SEND MAIL WITHOUT USING ANY TEMPLATE YOU CAN USE BELOW LOGIC

values = {}

values.update({'subject': 'Subject'})

values.update({'email_to': '[Email]'})

values.update({'body_html': body})

values.update({'body': body})

values.update({'res_id': ['CURRENT RECORD ID TO POST MESSAGE ON RECORD WALL']})

mail_mail_obj = self.pool.get('mail.mail')

msg_id = mail_mail_obj.create( cr, uid, values, context=context)

if msg_id:

mail_mail_obj.send(cr, uid, [msg_id], context=context)

OTHERWISE UPDATE THE BODY VALUE TO THE TEMPLATE AND SEND USING TEMPLATE ONLY

HOPE YOU GOT ME!!

1
Avatar
Annuleer
Dr Obx
Auteur

I would prefer to use template, much easier to customize.

Avatar
Dr Obx
Auteur Beste antwoord

By any chance, can I send an internal Odoo message instead or notification ?


0
Avatar
Annuleer
Pawan

if you are having object in list[1], then use list[1].name, or if list[1] contains only product id then browse product master using this id and then get the product name before forming string...

Dr Obx
Auteur

Sounds complicated :(

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to custom addons in Odoo is these steps are correct?
custom odoo
Avatar
Avatar
Avatar
2
mrt. 24
15873
Add company logo to template email, odoo 15
email template
Avatar
Avatar
Avatar
2
jan. 24
5244
Problem with email template (SOLVED) Opgelost
email template
Avatar
Avatar
2
jan. 24
11015
How to use IF ELSE (conditional clause) in email template
email template
Avatar
Avatar
1
mrt. 21
10464
How to send an automatic email on order confirmation Odoo 13 CE?
email odoo
Avatar
Avatar
1
okt. 20
8578
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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