def get_data(self, form):
total=0
res = {}
"""
Write sql or orm queries to get detail as a list of dict
"""
where_sql = []
where_sql_2=[]
if form['partner_ids']:
for ids5 in form['partner_ids']:
where_sql.append("r.id=%s"%(ids5))
if form['sale_mans_ids']:
for idd in form['sale_mans_ids']:
where_sql.append("u.id=%s"%(idd))
if form['branch_ids']:
for ide in form['branch_ids']:
where_sql.append("ss.id=%s"%(ide))
if where_sql:
#~ where_sql = ' and ( '+' or '.join(where_sql)+')'
where_sql = ' and '+' and '.join(where_sql)
else:
where_sql=''
print where_sql,"SWLL LL LL LL LL LL L"
ws = " sp.name like '%return%' "
self.cr.execute('''select sp.name as ref,
sp.date as rdate,part.name as partner,
sp.origin as origin,
sp.date_done as ref_dt,
prod.name_template as product,
sm.product_qty as qty
from
stock_picking sp join stock_move sm on (sm.picking_id = sp.id)
join
res_partner part on (part.id = sm.partner_id)
join
product_product prod on (prod.id = sm.product_id)
where
sp.name like '%return%'
and
sp.type='in'
and
sp.date >=%s
and
sp.date <=%s '''+ where_sql+'''
''' , (form['date_from'],form['date_to']))
data=self.cr.dictfetchall()
return data
please refere the query satetement cr.execute(), i want to print a return products from incoming shipment. So i use reference of table stock.picking for search a string with 'return', For that i am using like '%return' when using this one give a error message as tuple out of range..
I want a return products from stock move.
please suggest any solution for that problem?
Write above query in a variable & then in the next line print the variable so you will come to know where exactly the problem is. And then pass that variable in execute().
Thanks i got solution.