Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
4392 Vues

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)}

            


        
mrp_bom()

Avatar
Ignorer
Auteur

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

Meilleure réponse

Hi Jean,

Did you mean this...

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

Image

Avatar
Ignorer
Auteur Meilleure réponse
Avatar
Ignorer