콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
7779 화면
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
12월 24
5457
3
1월 20
5591
0
10월 15
3849
1
3월 15
9635
0
7월 24
1241