I am new to odoo and I received this error when I added a function in inherited sale_order_line class.Below is the code. Could you please let me know where I did the blunder?
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)
You are telling odoo to trigger this function when you change the salesman_id
and inside that function you change the same field so odoo will keep calling your method.
remove depends decorator because you are using it the wrong way use it only for compute field.
just keep onchange
and never set
the same field that you depend on to compute the field value.