Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4371 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

Hi Jean,

Did you mean this...

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

Image

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
Ảnh đại diện
Huỷ bỏ