CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
'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 <= 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, ' Left in stock: ',in_stock
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
About This Community
Odoo Training Center
|Asked: 1/5/16, 5:55 AM|
|Seen: 7027 times|
|Last updated: 1/6/16, 3:31 AM|