Odoo Help


Challenge: Show quantity on hand for specific store in BOM tree view

Jean-Claude Malengret
on 2/24/15, 5:12 PM 1,805 views

I need to get the quantity for each product for a specific location in the BOM structure tree view. My location name is "Raw Materials". 


class mrp_bom(osv.osv):
    _inherit = "mrp.bom"

    def _get_raw_qty(self, cr, uid, ids, field_name, args, context=None):
        res = {}

        for record in self.browse(cr, uid, ids,context=context):

            qty=<<<<<need quantity for product at specific location>>>>>>
            res[record.id] = qty
        return res
    _columns = {
        'qty_available': fields.related('product_id', 'qty_available', type="float", relation="product.product", string="Qty FG"),
        'cost_price': fields.related('product_id', 'cost_price', type="float", relation="product.product", string="Cost"),
        'standard_price': fields.related('product_id', 'standard_price', type="float", relation="product", string="Std Price"),
        'qty_raw': fields.char('Qty Raw', select=True, help='HELP text when hovering over the label in openERP'),
        'qty_raw': fields.function( _get_raw_qty, method=True, type='float', string='Raw Qty', store=False)}



I see the quantity on hand field you have there. By default it points to the stock location quantity. I need it to point to my raw materials location. I therefore cannot use a relative field but need a function field that can access the stock at location "Raw Materials" (ID:13). I just need the last step in retrieving the qty_on_hand in "Raw Materials" per product in the record list of the TREE VIEW for the BOM. Thanks in advance

Jean-Claude Malengret
on 2/25/15, 3:29 AM

Baiju KS

--Baiju KS--
| 5 5 8
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS
On 2/25/15, 12:06 AM

Hi Jean,

Did you mean this...

Can you please confirm this.. ?? So that i can give guidance...


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/24/15, 5:12 PM
Seen: 1805 times
Last updated: 3/16/15, 8:10 AM