跳至內容
選單
此問題已被標幟
1 回覆
4443 瀏覽次數

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?

頭像
捨棄
作者 最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
4月 24
2481
1
2月 25
1293
4
1月 24
1809
2
8月 22
5159
1
10月 20
1973