تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
7692 أدوات العرض
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)
الصورة الرمزية
إهمال

use "t-foreach"

أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
ديسمبر 24
5358
3
يناير 20
5514
0
أكتوبر 15
3772
1
مارس 15
9496
0
يوليو 24
1148