Skip to Content
Menú
This question has been flagged

Hey i am trying to loop over a list and based on index i want to write on my one2many field. What i wanna achieve is to write based on id as for line id = 1 list[0] should write and for line id = 2 next index should write and so on. Here is my code

main = http.request.env['performance.evaluation'].sudo().browse(kw.get('id'))
emp_self = request.httprequest.form.getlist('emp_self', type=None)
remarks = request.httprequest.form.getlist('remarks', type=None)
line_id = request.httprequest.form.getlist('id', type=None)
performance_id = request.httprequest.form.getlist('performance_id', type=None)
custom_id = main.sudo().search([('id', '=', id)])
for rec in custom_id.performance_lines:
final_id = rec.id
lines = [({
'emp_self': emp_self,
'remarks': remarks,
}) for emp_self, remarks in zip(emp_self, remarks)]
for line in range(len(lines)):
data = {
'performance_lines': [(1,final_id,lines[line])]
}
line += 1
main.sudo().search([('id', '=', id)]).write(data)
return request.render("gxs_performance_evaluation.evaluation_web_form_message", {})
I am doing this in controller but right now it is writing both indexes on same id and then it moves to next id.Kindly help
Avatar
Descartar
Related Posts Respostes Vistes Activitat
3
de jul. 17
11610
2
d’ag. 22
13690
0
d’oct. 18
3207
1
d’oct. 17
11313
1
de set. 16
3501