跳至内容
菜单
此问题已终结

Hey i have a controller in which i have called my custom line view and i have a button in each line and when the button is clicked it should increment a float field for that line only but issue i am facing is that i am unable to get the specific "id of line" where button is pressed , instead i always end up getting the first line id and it increments it.

Here is my code

main = http.request.env['odoocms.eo.elections'].sudo().browse(id)
vote_count = request.httprequest.form.getlist('vote_count', type=None)
fk_id = request.httprequest.form.getlist('fk_line_id', type=None)
custom_lines = http.request.env['odoocms.eo.election.students'].sudo().search(
[('election_student_id.id', '=', id)])

print(len(custom_lines))
print(custom_lines, 'aaa')
for rec in custom_lines:
rec.vote_count += 1
lines = {
'vote_count': rec.vote_count
}
final_id = rec.id
data = {
'election_students': [(1, final_id, lines)]
}
print('data', data)

main.sudo().search([('id', '=', id)]).write(data)

形象
丢弃
相关帖文 回复 查看 活动
1
7月 23
1955
2
12月 23
26105
3
7月 25
7144
1
9月 22
15920
1
9月 22
2653