Email Template
<record id="email_weekly_status_sales_manager" model="email.template">
<field name="name">Tickets - Weekly Status</field>
<field name="email_from">${user.company_id.email}</field>
<field name="subject">Weekly Status of Tickets</field>
<field name="email_to">${object.manager_mail_id}</field>
<field name="model_id" ref="jb_crm_claim.model_crm_claim"/>
<field name="auto_delete" eval="False"/>
<field name="body_html"><![CDATA[
<p>Hi,</p>Tickets which crossed deadlines and in Progress <br><br>
<table width="771" cellspacing="1" cellpadding="4" border="1" height="73">
<tbody>
<tr>
<th>Ticket Number</th>
<th> Customer name</th>
<th>Vendor name</th>
<th>Responsible</th>
<th>Status</th>
</tr>
% if object.get_record_ids():
% for values in object.get_record_ids()
<tr>
<td>${values['ticket_number']}</td>
<td>${values['partner_name']}<br></td>
<td>${values['vendor_name']}</td>
<td>${values['user_name']}<br></td>
<td>${values['state']}</td>
</tr>
% endfor
% endif
</tbody></table><br>
<p>Thank you</p>
]]></field>
</record>
Then write a python function to send the values to the template. In the template get_record_ids()
will call the function and pass the data to the templte.
def get_record_ids(self):
ticket_ids = self.search(['|', ('state', '=', 'open'), ('state', '=', 'pending')])
records=[]
for ticket_id in ticket_ids:
tickets={}
if ticket_id:
tickets['ticket_number'] = ticket_id.ticket_number
tickets['partner_name'] = ticket_id.partner_id.name
tickets['vendor_name'] = ticket_idr.vendor_id.name
tickets['user_name'] = ticket_id.user_id.name
tickets['state'] = ticket_id.state
records.append(tickets)
return records
This python code will send the data to the template.