odoo之帶出歷史訂單產品
阿新 • • 發佈:2017-05-18
change {} blog ont mat ima return 找到 packing
# 輸入客戶帶出它默認的發運方式和包裝方式
def on_change_partner_id_return(self,cr,uid,ids,partner_id,context=None):
result={}
if partner_id:# 如果存在
#找到滿足條件的值
obj=self.pool.get(‘res.partner‘).browse(cr,uid,partner_id,context=context)
#取出數據顯示在前端
fyfs=obj.send_type
zxbzfs=obj.packing_type
khmc=obj.name
# 返回結果
result[‘send_invoice_type‘]=fyfs
result[‘packing_type‘]=zxbzfs
print khmc
數據庫查詢語句,查出歷史訂單中的產品,去除重復數據
sql="select DISTINCT t2.product_id as product_id, t6.material as material,t6.cust_spec as cust_spec,t6.list_price as price,t4.name as uom, t3.packing_type1 as pick_type from res_partner t0 LEFT JOIN sale_order t1 on t0.id=t1.partner_id LEFT JOIN sale_order_line t2 on t2.order_id=t1.id LEFT JOIN sale_origin_line t3 on t2.order_id=t3.order_id LEFT JOIN product_uom t4 on t4.id=t2.product_uom left join product_product t5 on t5.id=t2.product_id left join product_template t6 on t6.id=t5.product_tmpl_id where t1.partner_id is not null and t0.name=‘%s‘"%(khmc)
print 555555555555555555555
history_line=[]
遍歷將數據打印到前端
for i in range(len(dict)):
print dict[i]
# history_line=[]
history_line.append({‘hproduct_id‘:dict[i][‘product_id‘] ,
‘hmaterial‘:dict[i][‘material‘],
‘hspec‘:dict[i][‘cust_spec‘],
‘hproduct_uom‘:dict[i][‘uom‘],
‘hprice‘:dict[i][‘price‘],
‘hpacking_type1‘:dict[i][‘pick_type‘]
})
result[‘history_order_line‘]=history_line
print 1111111111111111111111111111111111111111
print history_line
return {‘value‘:result}
如圖中 根據客戶名稱帶出歷史訂單產品
odoo之帶出歷史訂單產品