【问题标题】:how to update old records with computed field with store = True如何使用 store = True 更新具有计算字段的旧记录
【发布时间】:2020-10-14 11:33:02
【问题描述】:

我想更新现有记录的“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

我希望这个字段带有 store =True 但此字段在 store=True 的旧记录中未更新。请建议如何实现这一目标。

【问题讨论】:

  • 为什么使用api.constrains而不是api.depends作为装饰器?

标签: python xml odoo odoo-10 calculated-columns


【解决方案1】:

user10810227

制作qty_availablerelated字段

on_hand_qty=fields.Float(related='qty_available', string="Your Field")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    • 2012-09-09
    • 1970-01-01
    • 2015-08-14
    • 1970-01-01
    相关资源
    最近更新 更多