ValueError:Compute method failed to assign stock.move.line(12891,).is_lot
这是报错的代码
@api.depends('move_id.product_id.tracking')
def _compute_is_lot(self):
for rec in self:
if rec.move_id.product_id.tracking == 'lot':
rec.is_lot = True
修改之后,加个else
@api.depends('move_id.product_id.tracking')
def _compute_is_lot(self):
for rec in self:
if rec.move_id.product_id.tracking == 'lot':
rec.is_lot = True
else:
rec.is_lot = False
这篇博客讨论了在Odoo系统中遇到的一个错误:`ValueError: Compute method failed to assign stock.move.line(12891,) is_lot`。作者分析了问题源代码,并提出了一个解决方案,即在原有代码的基础上增加了一个else子句,确保当产品跟踪不为'lot'时,将`is_lot`设置为False,从而避免了计算方法的失败。

被折叠的 条评论
为什么被折叠?



