|
One silly question..
Hi I'm trying to write a select function with two string placeholders and I'm not able to write it..
I'm able to get a good result for the select with:
ids = self.pool.get('payment.type').search(cr,uid,[('name','ilike',value)], context=context) if ids: cr.execute('SELECT l.id ' \ 'FROM account_move_line l, account_invoice i, account_voucher j ' \ 'WHERE (l.move_id = j.move_id AND j.payment_type = ' + str(ids[0]) + ') OR (l.move_id = i.move_id AND i.payment_type in (%s))' % (','.join(map(str, ids)))) res = cr.fetchall()
But it's not a good code...
I want to write something as:
ids = self.pool.get('payment.type').search(cr,uid,[('name','ilike',value)], context=context) if ids: cr.execute('SELECT l.id ' \ 'FROM account_move_line l, account_invoice i, account_voucher j ' \ 'WHERE (l.move_id = j.move_id AND j.payment_type in (%s)) ') OR (l.move_id = i.move_id AND i.payment_type in (%s))' % (','.join(map(str, ids)))) res = cr.fetchall()
But, of course, I get: TypeError: not enough arguments for format string
How can I pass the value for both placeholders?. I'm not able to find the correct syntax..
Thanks in advance
|