Skip to Content
Menu
This question has been flagged

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)

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
liep. 23
1947
2
gruod. 23
26102
3
liep. 25
7140
1
rugs. 22
15916
1
rugs. 22
2651