Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
4446 Tampilan

Hello I'm trying to compute a boolean field, I've tried many attemps like:


for record in self:

  if record.x_studio_photo_quant ==2:

    record[("x_studio_photo_check")]==bool(True)


or

for record in self:

  if record.x_studio_photo_quant ==2:

  a ==True

    record[("x_studio_photo_check")]=a


But they don't work, how can I fix this?

Avatar
Buang
Penulis Jawaban Terbai

The problem was that 2 is not int but is a string,

So this worked:

for record in self:

  if record.x_studio_photo_quant =='2':

    a =bool(1)

    record[("x_studio_photo_check")]=a

or even simplier


for record in self:

  if record.x_studio_photo_quant =='2':

    record[("x_studio_photo_check")]=True

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Apr 24
2488
1
Feb 25
1296
4
Jan 24
1812
2
Agu 22
5159
1
Okt 20
1974