def onchange_picking_type_id(self, cr, uid,ids, picking_type_id, context=None):
if picking_type_id in (12,13,18,17):
domain={}
domain['product_id']=[('product_id','in',[])]
sql="select t0.id from product_product t0 LEFT JOIN product_template t1 on t0.product_tmpl_id=t1.id where t1.categ_id=4"
cr.execute(sql)
dict=cr.dictfetchall()
valu=[]
for i in range(len(dict)):
dict2=dict[i]
valu.append(dict2['id'])

domain['product_id']=[('id','in',valu)]
else:
domain={}

return {'domain':domain}
<field name="picking_type_id" invisible="1" on_change="onchange_picking_type_id(picking_type_id)"/>

 

 

字符串排序bom标号:思路如下

aa='1.2.6'
bb='1.3.5.6'
cc='1.3.6.9.5'
dd='5.6'
list1=[aa.split('.'),bb.split('.'),cc.split('.'),dd.split('.')]
sorted(list1)

[['1', '2', '6'], ['1', '3', '5', '6'], ['1', '3', '6', '9', '5'], ['5', '6']]




list1=[['1', '2', '6'], ['7','8'],['1', '3', '5', '6'], ['1', '3', '6', '9', '5'], ['5', '6']]
for index,item in enumerate(sorted(list1)):
print index,item

 

心有猛虎,细嗅蔷薇