Skip to Content
Menu
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
Discard
Related Posts Replies Views Activity
3
Jul 17
10373
2
Aug 22
11999
0
Oct 18
2662
1
Oct 17
10219
1
Sep 16
2899