I need to get product quantity on product onchange. There is a model stock_quant, which records all quantity activity.
How can I get the available quantity of the product? I am writing following function and getting stock_quantity lines but not sure how to filter out the available quantity -
@api.multi
@api.onchange('product_id')
def product_location_change(self):
if self.product_id:
stock_qty_obj = self.env['stock.quant']
stock_qty_lines = stock_qty_obj.search([['product_id', '=', self.product_id.id]])
print stock_qty_lines
# TODO: GET AVAILABLE QUANTITY OF THE PRODUCT