Skip to Content
Menu
This question has been flagged
3692 Views

How to pass data into template with some formatting elements ?

Example:

my template:

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data noupdate="0">

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

<field name="name">A_product_multi</field>

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

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

<field name="model_id" ref="iProdLoc.model_stock_check"/>

<field name="email_to" >rob@net.net</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;

}

.red {

color: #FF0000;

}

</style>

<field name="email_body"/>

<div style="padding: 10px; width:100%; font-size: 40px; height: 80px;top: 0px; color:#FFFFFF; background-color: #2EA2D2; margin-left: auto;margin-right: auto;">

<h1>GNG Computers</h1></div>

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

<p class="red">Product/s must be ordered/purchased immediately</p>${object.emailbody}

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

</div>

]]>

</field>

</record>


module generate some data but I can't add it into template ...

my data:

# loop create/appending data into string

for pop in email:

product = self.pool.get('product.product').browse(cr, uid, pop['product_id'])

product_line = """ Product Name: %s <br/>"""%(product.name)

body += """<div>%s</div> <br/>""" %(product_line)

pr = obj.write({'emailbody':body})

#sending email

self.multi(cr, uid, ids, context=context)

How to pass this string/data into template with all formatting tags ?

I would like to put there a table for example ......

table = """  <table> <tr><td>something</td></tr> <tr><td>something</td></tr> <tr><td>something</td></tr> <tr><td>something</td></tr> <tr><td>something</td></tr> <tr><td>something</td></tr> <tr><td>something</td></tr> </table>"""

Is it possible ?

Or maybe I have to change whole template?

Please help


Avatar
Discard