Skip to Content
Menu
This question has been flagged
1 Reply
2640 Views

i want to get the current stock of product in manfacturing indent lines , how do i get it anyone please tell me

Avatar
Discard
Best Answer

Hi,

In py you can get the stock of  product , based on the lot if tracking is true in product master and also based on the location if you want

qty_available = line.product_id.with_context(lot_id=line.prodlot_id and line.prodlot_id.id or False, location=your_location_id.id).qty_available

Here line in mean the manfacturing indent line , you can iterate in for loop for all the lines.

for odoo 8 ,

You can define a quantity field in which you want to show the stock.

you can do it using a button function,

def check_available_quants(self, cr, uid, ids, context=None):

       line_obj = self.pool.get('your.line')

        quant_obj = self.pool.get('stock.quant')

        qty_available = 0

        for each in self.browse(cr, uid, ids):

            for tab in each.lines:

                qty_available = 0

                quant_search = quant_obj.search(cr, uid, [('location_id', '=', tab.location_id.id), ('product_id', '=',tab.product_id.id)])

                for quant_ids in quant_search:

                    quant_bro = quant_obj.browse(cr, uid, quant_ids)

                    qty_available += quant_bro.qty

                line_obj.write(cr, uid, [tab.id], {'quantity': qty_available})

        return True

and use this in your form view.

Avatar
Discard
Author

i dont get you man , i have a product in line i want to show the total on hand stock in the same line when the product is displayed

Sorry i didn't notice the version, i have updated my answer

Related Posts Replies Views Activity
1
Aug 23
12548
1
Aug 23
11053
1
Jul 23
7228
4
Apr 23
8676
2
Feb 23
17598