Python 运行时错误:超过Odoo 10中的最大递归深度

Python 运行时错误:超过Odoo 10中的最大递归深度,python,odoo,odoo-10,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)],

我是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)

当您更改
saller\u id
时,您告诉odoo触发此函数,并且在该函数中更改相同的字段,以便odoo继续调用您的方法

remove depends decorator because you are using it the wrong way use it only for compute field.
只要保持
onchange
,并且永远不要
set
计算字段值所依赖的相同的字段