Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2613 มุมมอง

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)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 23
1962
2
ธ.ค. 23
26112
3
ก.ค. 25
7149
1
ก.ย. 22
15927
1
ก.ย. 22
2674