콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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
1960
2
12월 23
26107
3
7월 25
7148
1
9월 22
15925
1
9월 22
2668