Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
4516 Visninger

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
Kassér
Forfatter Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
apr. 24
2584
1
feb. 25
1363
4
jan. 24
1901
2
aug. 22
5247
1
okt. 20
2037