Skip to Content
Menu
This question has been flagged
3 Replies
6908 Views
this is on py:
I need to loop the table td

please help me, thanks


THIS IS MY CODE:

all_contract_id = self.env['hr.contract'].search([]) --- This is the one I need to loop in the td
template = self.env.ref('hr_data.email_template_contract_pending')
template_rec = self.env['mail.template'].sudo().browse(template.id)
values = {}
values.update({'email_to': email_to,
'send_to': send_to,
'body_html': "<p>Dear Human Resource," +
"<br/><br/> This email is to notify you that " + con.employee_id.name +"'s deployment to " + con.partner_id.name + " was on its fifth (5)month and will be expired thirty (30) days from now, "+ date_today.strftime("%B %d, %Y")+
"<br/><br/>" +
con.employee_id.name +"'s"+ " Employment History"
" <table style='border: 1px solid;background-color:#FFFFFF;width:80%;text-align:center;border-spacing:0;'> "
" <thead style='background-color:black;'>"
" <tr>"
" <th style='padding:10px;font-size:15px;color:white;text-align:center;'>Assigned Company</th> "
" <th style='padding:10px;font-size:15px;color:white;text-align:center;'>Start Date</th> "
" <th style='padding:10px;font-size:15px;color:white;text-align:center;'>End Date</th> "
" <th style='padding:10px;font-size:15px;color:white;text-align:center;'>Contract Duration with Client</th> "
" <th style='padding:10px;font-size:15px;color:white;text-align:center;'>Contract Duration with Us "
" </tr>"
"</thead>"
"<tbody>"
" <tr >"
"<td style='border: 1px solid;padding:10px;font-size:13px;'>Sample Company</td>"
"<td style='border: 1px solid;padding:10px;font-size:13px;'>03-15-2018</td>"
"<td style='border: 1px solid;padding:10px;font-size:13px;'>02-14-2019</td>"
"<td style='border: 1px solid;padding:10px;font-size:13px;'>6 months</td>"
"<td style='border: 1px solid;padding:10px;font-size:13px;'>1 year</td>"
"</tr>"
"<tbody>"
"</table>"
" </p>"})
template_rec.write(values)
template_rec.send_mail(con.id, force_send=True)
Avatar
Discard

use "t-foreach"

Best Answer

Hello,


Use the following to loop through objects. Lets say the field you want to loop is called "lines":

The below will loop through all the field lines and output the value of the name field.


% for row in object.lines:

            <td> Deposit : ${row.name}</td>

            % endfor

Avatar
Discard
Best Answer

You may want to use a QWeb template and read the documentation: https://www.odoo.com/documentation/12.0/reference/qweb.html#loops

Avatar
Discard
Related Posts Replies Views Activity
3
Jan 20
4413
2
Oct 19
3884
0
Oct 15
2680
1
Mar 15
8059
0
Jul 24
218