Runtime error: maximum recursion depth exceeded in Odoo 10
Runtime error: maximum recursion depth exceeded in Odoo 10
我是odoo的新手,当我在继承sale_order_line中添加一个函数时收到这个错误class.Below是代码。你能告诉我我哪里做错了吗?
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
而永远不要 set
您 依赖 计算字段的 相同字段 值。
我是odoo的新手,当我在继承sale_order_line中添加一个函数时收到这个错误class.Below是代码。你能告诉我我哪里做错了吗?
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
而永远不要 set
您 依赖 计算字段的 相同字段 值。