How to use field value of one object in another using self.pool.get in openerp?

StackOverflow https://stackoverflow.com/questions/22839794

  •  27-06-2023
  •  | 
  •  

문제

This is my code in .py file.I want to fetch value of field list_price in product.product and use it in my custom module which inherits sale.order. Can i store the value of list_price field in my custom field i.e qty_available? When i print value of wg_qty_avail it shows None even list_price is having value 2000

class practice(osv.osv):

_inherit = 'sale.order'
_columns = {
    'qty_available': fields.float('Quantity'),
}

def get_val(self, cr, uid, id, product, context=None):

    result={}
    wg_qty_avail = self.pool.get('product.product').browse(cr, uid,product,context=context).list_price
    print "---------------------------", wg_qty_avail
    result['qty_available'] = wg_qty_avail

practice()

xml file is ok..it calls the method get_val by a button click.

Please help.Where am i wrong..

도움이 되었습니까?

해결책

You are not assigning the value to 'qty_available' field correctly

Remove result['qty_available'] = wg_qty_avail

return  {'value': {'qty_available':wg_qty_avail}}

Hope this helps...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top