تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2615 أدوات العرض

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
يوليو 23
1962
2
ديسمبر 23
26112
3
يوليو 25
7150
1
سبتمبر 22
15931
1
سبتمبر 22
2678