[code]
....
'current_stock': fields.function(_get_current_stock, type='char', string='Currently in stock'),
....
#getting quants from stock.quant to put into field 'current_stock'
def _get_current_stock(self, cr, uid, ids, field_name, arg, context=None):
res = []
in_stock = 0
tot_sold = 0
product_id = 0
for obj in self.browse(cr, uid, ids, context=context):
#first query read data about product sold
cr.execute(""" select sum(qty) from stock_quant where product_id = %s and location_id = 7;""" %(obj.product_id.id))
tot_sold = cr.fetchall()
#second query read data adout products left in stock
cr.execute(""" select sum(qty) from stock_quant where product_id = %s and location_id != 7;""" %(obj.product_id.id))
in_stock = cr.fetchall()
res = in_stock[0] <= once i add this, everything stops and getting error, of course if I remove it got no error but also current_stock stays empty because res = ''
# I can print value of tot_sold and in_stock
print '|| Total sell: ', tot_sold[0], ' Left in stock: ',in_stock[0]
return res
Getting this error and don't know how to extract data from res and populate with related field 'current_stock'
new_values = dict(values)
TypeError: cannot convert dictionary update sequence element #0 to a sequence
Please use significant titles, this forum rule is also valid for newbies :-)