Skip to Content
Menu
This question has been flagged
1 Reply
9474 Views
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?

Avatar
Discard

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().

Author

Thanks i got solution.

Author Best Answer

I got a solution, Instead of using like, i use regular expression to accomplish that task, [i.e]

rather using, name like '%return', use name ~* 'return'. It works.

Thanks,

Avatar
Discard
Related Posts Replies Views Activity
2
May 24
1128
1
Nov 22
1308
1
Sep 22
2156
1
Jul 15
3306
0
Nov 24
8