gpt4 book ai didi

python - @api.depends 依赖于非存储字段不起作用

转载 作者:行者123 更新时间:2023-12-01 01:50:03 25 4
gpt4 key购买 nike

我需要存储一个计算字段,以便我可以在 TreeView 中的 group by 中使用它,问题是一旦我添加 store=True,即使使用 @api.depends,该字段也不会更新并返回 0

P.S:amount_total也是一个计算字段,所以也许这就是问题所在,请帮助我

这是我的代码:

@api.one
@api.depends('amount_total')
def check_negatif_or_positif(self):
if (self.picking_type_id.name =='Receptions'):
self.amount_calcul = self.amount_total * (-1)

else:
self.amount_calcul = self.amount_total

amount_calcul= fields.Float(compute='check_negatif_or_positif ,string='Amount' ,store=True)

谢谢

最佳答案

要存储计算字段,请在字段中指定 readonly=False。

关于python - @api.depends 依赖于非存储字段不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50816723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com