@api.依赖在不工作的非存储字段上

2024-05-23 19:44:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要存储一个计算字段,这样我就可以在树状视图中的groupby中使用它,问题是一旦我添加store=True,该字段就不能更新并返回0@api.依赖在

注: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)

谢谢


Tags: orstore代码self视图apitruecheck