Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Email template in custom module - passing data

Subscribe

Get notified when there's activity on this post

This question has been flagged
emailcustomtemplateodoo
7 Replies
17087 Views
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
Discard
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Best Answer

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
Discard
Dr Obx
Author

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
Best Answer

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
Discard
Dr Obx
Author

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

Avatar
Dr Obx
Author Best Answer

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


0
Avatar
Discard
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
Author

Sounds complicated :(

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to custom addons in Odoo is these steps are correct?
custom odoo
Avatar
Avatar
Avatar
2
मार्च 24
15888
Add company logo to template email, odoo 15
email template
Avatar
Avatar
Avatar
2
जन॰ 24
5247
Problem with email template (SOLVED) Solved
email template
Avatar
Avatar
2
जन॰ 24
11021
How to use IF ELSE (conditional clause) in email template
email template
Avatar
Avatar
1
मार्च 21
10465
How to send an automatic email on order confirmation Odoo 13 CE?
email odoo
Avatar
Avatar
1
अक्तू॰ 20
8579
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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