# 输入客户带出它默认的发运方式和包装方式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} 如图中 根据客户名称带出历史订单产品
时间: 2024-10-21 07:53:21