function类型的字段,怎么在试图做筛选条件啊???????????
-
def _get_stock_qty(self, cr, uid, ids, field_names=None, arg=False, context=None):
res = {}
print ids
if len(ids) == 0:
return res
if context and context.has_key('location'):
for id in ids:
cr.execute(
'''select stock_qty get_stock_qty from starmerx_inventory where location_id=%s and type='shelf' and product_id=%s''',
(context.get('location'), id,))
result = cr.dictfetchall()
if result:
res[id] = result[0]['get_stock_qty']
else:
print id
res[id] = 0
return res字段的定义:不保存在数据库
_columns = {
'get_newstock_qty': fields.function(_get_stock_qty, string=u"库存数量", type='integer'),
}我现在想搜索库存大于0的。在xml
《filter string="库存大于0" domain="[('get_newstock_qty', '>', '0')]"/》
不起作用。何解?