运行时错误:Odoo 10中超出了最大递归深度

时间:2018-04-04 13:46:22

标签: python odoo odoo-10

我是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):
        print '$$$$$$$$$$$$$$$$$$', self.product_id
        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)

1 个答案:

答案 0 :(得分:1)

当你改变salesman_id时,你正在告诉odoo触发这个功能,并且在你改变同一个字段的内部,所以odoo会继续调用你的方法。

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

只需保留onchange而不是set 依赖于相同字段来计算字段值。