gpt4 book ai didi

python - 运行时错误: maximum recursion depth exceeded in Odoo 10

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

我是 odoo 新手,当我在继承的 sale_order_line 类中添加函数时收到此错误。下面是代码。您能告诉我我在哪里犯了错误吗?

class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

product_id = fields.Many2one('product.product', string='Product', domain=[('sale_ok', '=', True)],
change_default=True, ondelete='restrict', required=True)

salesman_id = fields.Char(string='Salesman')

@api.onchange(product_id)
@api.depends(salesman_id)
def user_id_tracking(self):
self.env.cr.execute("""SELECT user_id FROM stock_location as sl WHERE sl.id in
(SELECT sq.location_id FROM stock_change_product_qty as sq,product_template as pt
WHERE sq.product_id = %d)""", self.product_id)
res = self.env.cr.fetchone()
self.salesman_id = res[0]

lot_id = fields.Many2one('stock.production.lot', string='Lot/Serial Number', copy=False)

最佳答案

您告诉 odoo 在更改 salesman_id 时触发此函数,并且在该函数内更改相同的字段,以便 odoo 将继续调用您的方法。

remove depends decorator because you are using it the wrong way use it only for compute field.

只需保持onchange,并且永远不要设置依赖计算字段值的同一字段

关于python - 运行时错误: maximum recursion depth exceeded in Odoo 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49652697/

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