Community mailing list archives

community@mail.odoo.com

Re: How to get product total quantity and product quantity on location

by
Md. Tanzilul Hasan Khan
- 10/25/2016 03:07:28
I got help at other place. Here is the solution if anyone needs it -

product=self.product_id
available_qty = product.with_context({'location':self.source_location.id}).qty_available

Best Regards,
Tanzil

On Sun, Oct 23, 2016 at 6:31 PM, MD Tanzilul Hasan Khan <ponkhi403@gmail.com> wrote:
I need to get product quantity on product onchange. There is a model stock_quant, that records all quantity activity.

How can I get the total available quantity of the product? 
How can I get available quantity in stock locations?

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

--
MD. Tanzilul Hasan Khan.







--
MD. Tanzilul Hasan Khan.