跳至内容
菜单
此问题已终结
1 回复
4441 查看

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
2479
1
2月 25
1289
4
1月 24
1806
2
8月 22
5150
1
10月 20
1967