如何使用store = True更新带有计算字段的旧记录

问题描述

我想更新现有记录的“ on_hand_qty”字段

 _inherit="product.product"
     
    on_hand_qty=fields.Float('onhand',compute='copy_quant',store=True)
    
    
    @api.constrains('qty_available')
    def copy_quant(self):
        for rec in self:
            rec.on_hand_qty = rec.qty_available

我想要带有存储= True的此字段 但此字段不会在store = True的旧记录中更新。请建议如何实现。

解决方法

user10810227

设置related的{​​{1}}字段

qty_available