diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 5ccfbdb23d8..b71e2daa447 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -673,9 +673,10 @@ true, it will allow you to hide the event alarm information without removing it. new_res_alarm = res_alarm_obj.create(cr, uid, val, context=context) else: new_res_alarm = alarm_ids[0] - cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \ - where id=%s' % (model_obj._table, \ - cal_alarm.id, new_res_alarm, data.id)) + cr.execute('UPDATE %s ' % model_obj._table + \ + ' SET base_calendar_alarm_id=%s, alarm_id=%s ' \ + ' WHERE id=%s', + (cal_alarm.id, new_res_alarm, data.id)) self.do_alarm_unlink(cr, uid, [data.id], model) if basic_alarm: @@ -697,9 +698,10 @@ true, it will allow you to hide the event alarm information without removing it. 'user_id': uid } alarm_id = alarm_obj.create(cr, uid, vals) - cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \ - where id=%s' % (model_obj._table, \ - alarm_id, basic_alarm.id, data.id)) + cr.execute('UPDATE %s ' % model_obj._table + \ + ' SET base_calendar_alarm_id=%s, alarm_id=%s ' + ' WHERE id=%s', \ + ( alarm_id, basic_alarm.id, data.id) ) return True def do_alarm_unlink(self, cr, uid, ids, model, context=None): @@ -722,7 +724,7 @@ true, it will allow you to hide the event alarm information without removing it. if alarm_ids: alarm_obj.unlink(cr, uid, alarm_ids) cr.execute('Update %s set base_calendar_alarm_id=NULL, alarm_id=NULL\ - where id=%s' % (model_obj._table, datas.id)) + where id=%%d' % model_obj._table,(datas.id,)) return True res_alarm() @@ -994,10 +996,10 @@ class calendar_event(osv.osv): context = {} cr.execute("UPDATE %s set freq='None',interval=0,count=0,end_date=Null,\ mo=False,tu=False,we=False,th=False,fr=False,sa=False,su=False,\ - day=0,select1='date',month_list=Null ,byday=Null where id=%s" % (self._table, id)) + day=0,select1='date',month_list=Null ,byday=Null where id=%%s" % (self._table), (id,)) if not value: - cr.execute("UPDATE %s set rrule_type='none' where id=%s" % (self._table, id)) + cr.execute("UPDATE %s set rrule_type='none' where id=%%s" % self._table,(id,)) return True val = {} for part in value.split(';'): @@ -1063,7 +1065,7 @@ class calendar_event(osv.osv): 'rule_type': rrule_type, 'id': id, }) - cr.execute(qry % val) + cr.execute(qry, val) # Hopefully psycopg2 works with dicts. But, FIXME return True def _get_rulestring(self, cr, uid, ids, name, arg, context=None): @@ -1081,7 +1083,7 @@ class calendar_event(osv.osv): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False - cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event)) + cr.execute("UPDATE %s set exrule=Null where id=%%s" % self._table,( event,)) elif datas.get('rrule_type') == 'custom': if datas.get('interval', 0) < 0: raise osv.except_osv('Warning!', 'Interval can not be Negative') @@ -1258,7 +1260,7 @@ true, it will allow you to hide the event alarm information without removing it. if defaults.get('location'): qry += ", location = '%(location)s'" qry += "WHERE id = %s" % (event_id) - cr.execute(qry %(defaults)) + cr.execute(qry, defaults) return True @@ -1283,8 +1285,7 @@ true, it will allow you to hide the event alarm information without removing it. if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, m.date, m.date_deadline, m.duration, \ m.exdate, m.exrule, m.recurrent_id, m.recurrent_uid from " + self._table + \ - " m where m.id in ("\ - + ','.join(map(lambda x: str(x), ids))+")") + " m where m.id = ANY(%s)", (ids,) ) count = 0 for data in cr.dictfetchall(): @@ -1683,10 +1684,8 @@ class calendar_todo(osv.osv): @param context: A standard dictionary for contextual values """ - event = self.browse(cr, uid, id, context=context) - cr.execute("UPDATE %s set date_start='%s' where id=%s" \ - % (self._table, value, id)) - return True + assert name == 'date' + return self.write(cr, uid, id, { 'date_start': value }, context=context) _columns = { 'date': fields.function(_get_date, method=True, fnct_inv=_set_date, \ diff --git a/addons/base_calendar/wizard/base_calendar_invite_attendee.py b/addons/base_calendar/wizard/base_calendar_invite_attendee.py index 98369962ab7..47f5681addf 100644 --- a/addons/base_calendar/wizard/base_calendar_invite_attendee.py +++ b/addons/base_calendar/wizard/base_calendar_invite_attendee.py @@ -159,8 +159,8 @@ send an Email to Invited Person') if not partner_id: return {'value': {'contact_ids': []}} - cr.execute('select id from res_partner_address \ - where partner_id=%s' % (partner_id)) + cr.execute('SELECT id FROM res_partner_address \ + WHERE partner_id=%s', (partner_id,)) contacts = map(lambda x: x[0], cr.fetchall()) return {'value': {'contact_ids': contacts}} diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 88b0549a3de..bcc624d6a67 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -61,10 +61,10 @@ def uid2openobjectid(cr, uidval, oomodel, rdate): model_obj = pooler.get_pool(cr.dbname).get(model) if (not model == oomodel) or (not dbname == cr.dbname): return (False, None) - qry = 'select distinct(id) from %s' % model_obj._table + qry = 'SELECT DISTINCT(id) FROM %s' % model_obj._table if rdate: - qry += " where recurrent_id='%s'" % (rdate) - cr.execute(qry) + qry += " WHERE recurrent_id=%s" + cr.execute(qry, (rdate,)) r_id = cr.fetchone() if r_id: return (id, r_id[0]) @@ -364,8 +364,8 @@ class CalDAV(object): model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): - cr.execute('select id from %s where recurrent_uid=%s' - % (model_obj._table, data[map_field])) + cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table, + (data[map_field],)) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: r_datas = model_obj.read(cr, uid, r_ids, context=context) @@ -715,8 +715,9 @@ class basic_calendar_line(osv.osv): @param context: A standard dictionary for contextual values """ - cr.execute("Select count(id) from basic_calendar_lines \ - where name='%s' and calendar_id=%s" % (vals.get('name'), vals.get('calendar_id'))) + cr.execute("SELECT COUNT(id) FROM basic_calendar_lines \ + WHERE name='%s' AND calendar_id=%s", + (vals.get('name'), vals.get('calendar_id'))) res = cr.fetchone() if res: if res[0] > 0: @@ -797,8 +798,8 @@ class basic_calendar_fields(osv.osv): @param context: A standard dictionary for contextual values """ - cr.execute('select name from basic_calendar_attributes \ - where id=%s' % (vals.get('name'))) + cr.execute('SELECT name FROM basic_calendar_attributes \ + WHERE id=%s', (vals.get('name'),)) name = cr.fetchone() name = name[0] if name in ('valarm', 'attendee'): diff --git a/addons/caldav/calendar_collection.py b/addons/caldav/calendar_collection.py index 06e799b1686..8dd4ff053c9 100644 --- a/addons/caldav/calendar_collection.py +++ b/addons/caldav/calendar_collection.py @@ -34,11 +34,11 @@ class calendar_collection(osv.osv): def _get_root_calendar_directory(self, cr, uid, context=None): objid = self.pool.get('ir.model.data') try: - mid = objid._get_id(cr, uid, 'document', 'dir_calendars') + mid = objid._get_id(cr, uid, 'document', 'dir_calendars') if not mid: return False - root_id = objid.read(cr, uid, mid, ['res_id'])['res_id'] - root_cal_dir = self.browse(cr, uid, root_id, context=context) + root_id = objid.read(cr, uid, mid, ['res_id'])['res_id'] + root_cal_dir = self.browse(cr,uid, root_id, context=context) return root_cal_dir.name except Exception, e: import netsvc @@ -67,7 +67,7 @@ class calendar_collection(osv.osv): ], limit=1, context=context) root_cal_dir = self._get_root_calendar_directory(cr, uid, context=context) - if not calendar_ids: + if not calendar_ids: return root_cal_dir calendar_id = calendar_ids[0] calendar = calendar_obj.browse(cr, uid, calendar_id, diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index 80363f719fd..3132367d8bf 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -114,13 +114,16 @@ class pos_order(osv.osv): res = {} val=None for order in self.browse(cr, uid, ids): - cr.execute("select date_payment from pos_order where id=%d"%(order.id)) + cr.execute("SELECT date_payment FROM pos_order WHERE id=%s", (order.id,)) date_p=cr.fetchone() date_p=date_p and date_p[0] or None if date_p: res[order.id]=date_p return res - cr.execute(" SELECT max(l.date) from account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o where i.move_id=m.id and l.move_id=m.id and l.reconcile_id=r.id and o.id=%d and o.invoice_id=i.id"%(order.id)) + cr.execute(" SELECT max(l.date) " + " FROM account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o " + " WHERE i.move_id=m.id AND l.move_id=m.id AND l.reconcile_id=r.id AND o.id=%s AND o.invoice_id=i.id", + (order.id,)) val=cr.fetchone() val= val and val[0] or None if val: @@ -135,7 +138,7 @@ class pos_order(osv.osv): res = {} val=None for order in self.browse(cr, uid, ids): - cr.execute("select date_validation from pos_order where id=%d"%(order.id)) + cr.execute("SELECT date_validation FROM pos_order WHERE id=%s", (order.id,)) date_p=cr.fetchone() date_p=date_p and date_p[0] or None if date_p: @@ -146,7 +149,7 @@ class pos_order(osv.osv): if line.discount > discount_allowed: return {order.id: None } if order.amount_paid == order.amount_total and not date_p: - cr.execute("select max(date) from account_bank_statement_line where pos_statement_id=%d"%(order.id)) + cr.execute("SELECT MAX(date) FROM account_bank_statement_line WHERE pos_statement_id=%s", (order.id,)) val=cr.fetchone() val=val and val[0] or None if order.invoice_id and order.invoice_id.move_id and not date_p and not val: @@ -240,15 +243,15 @@ class pos_order(osv.osv): comp=res_obj.browse(cr,uid,uid).company_id.company_discount or 0.0 else: comp= company_disc[0] and company_disc[0].company_id and company_disc[0].company_id.company_discount or 0.0 - cr.execute("select discount from pos_order_line where order_id=%s and discount <= %s"%(ids[0],comp)) + cr.execute("select discount from pos_order_line where order_id=%s and discount <= %s", (ids[0],comp)) res=cr.fetchone() - cr.execute("select discount from pos_order_line where order_id=%s and discount > %s"%(ids[0],comp)) + cr.execute("select discount from pos_order_line where order_id=%s and discount > %s", (ids[0],comp)) res2=cr.fetchone() - cr.execute("select journal_id from account_bank_statement_line where pos_statement_id=%s "%(ids[0])) + cr.execute("select journal_id from account_bank_statement_line where pos_statement_id=%s ", (ids[0],)) res3=cr.fetchall() list_jrnl=[] for r in res3: - cr.execute("select id from account_journal where name= '%s' and special_journal='t'"%(r[0])) + cr.execute("select id from account_journal where name= '%s' and special_journal='t'", (r[0],)) res3=cr.fetchone() is_special=res3 and res3[0] or None if is_special: @@ -479,7 +482,7 @@ class pos_order(osv.osv): continue prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid, prop_ids[0]).value_reference - cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order.shop_id.warehouse_id.id)) + cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id=%s", (order.shop_id.warehouse_id.id,)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index fd0eb54bc3f..16181e15a2a 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -28,7 +28,7 @@ class pos_details(report_sxw.rml_parse): def _get_invoice(self,inv_id,user): res={} if inv_id: - self.cr.execute("select name from account_invoice as ac where id = %d" %(inv_id)) + self.cr.execute("select name from account_invoice as ac where id = %s", (inv_id,)) res = self.cr.fetchone() return res[0] else: diff --git a/addons/point_of_sale/wizard/pos_box_entries.py b/addons/point_of_sale/wizard/pos_box_entries.py index f7349726033..9428d0ec1ae 100644 --- a/addons/point_of_sale/wizard/pos_box_entries.py +++ b/addons/point_of_sale/wizard/pos_box_entries.py @@ -36,7 +36,7 @@ def get_journal(self, cr, uid, context): obj = self.pool.get('account.journal') statement_obj = self.pool.get('account.bank.statement') - cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid)) + cr.execute("SELECT DISTINCT journal_id from pos_journal_users where user_id=%s order by journal_id", (uid,)) j_ids = map(lambda x1: x1[0], cr.fetchall()) ids = obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)]) obj_ids= statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)]) diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py index f12a0a16c99..a3650a6f76a 100644 --- a/addons/point_of_sale/wizard/pos_close_statement.py +++ b/addons/point_of_sale/wizard/pos_close_statement.py @@ -40,7 +40,8 @@ class pos_close_statement(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') statement_obj = self.pool.get('account.bank.statement') journal_obj = self.pool.get('account.journal') - cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid)) + cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users " + "WHERE user_id=%s ORDER BY journal_id", (uid,)) j_ids = map(lambda x1: x1[0], cr.fetchall()) journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)]) ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)]) diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py index 0b8219d949b..985324851f6 100644 --- a/addons/point_of_sale/wizard/pos_open_statement.py +++ b/addons/point_of_sale/wizard/pos_open_statement.py @@ -42,7 +42,8 @@ class pos_open_statement(osv.osv_memory): statement_obj = self.pool.get('account.bank.statement') sequence_obj = self.pool.get('ir.sequence') journal_obj = self.pool.get('account.journal') - cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid)) + cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users " + "WHERE user_id=%s ORDER BY journal_id", (uid,)) j_ids = map(lambda x1: x1[0], cr.fetchall()) journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)]) diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 8330be2772c..961ba7949a4 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -42,7 +42,8 @@ class pos_make_payment(osv.osv_memory): active_id = context and context.get('active_id',False) if active_id: j_obj = self.pool.get('account.journal') - cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid)) + cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users " + "WHERE user_id=%d ORDER BY journal_id", (uid,)) j_ids = map(lambda x1: x1[0], cr.fetchall()) journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)]) diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index dfc16e0ff96..24ddf59a15a 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -171,7 +171,9 @@ class pos_return(osv.osv_memory): for order_id in order_obj.browse(cr, uid, [active_id], context=context): prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid, prop_ids[0]).value_reference - cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) + cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w " + "WHERE w.lot_stock_id=s.id AND w.id=%s ", + (order_id.shop_id.warehouse_id.id,)) res = cr.fetchone() location_id = res and res[0] or None stock_dest_id = val.id @@ -254,7 +256,9 @@ class add_product(osv.osv_memory): qty=data['quantity'] prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid, prop_ids[0]).value_reference - cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) + cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w " + "WHERE w.lot_stock_id=s.id AND w.id=%s ", + (order_id.shop_id.warehouse_id.id,)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id @@ -316,7 +320,9 @@ class add_product(osv.osv_memory): for order_id in order_obj.browse(cr, uid, active_ids, context=context): prop_ids =property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid, prop_ids[0]).value_reference - cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) + cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w " + " WHERE w.lot_stock_id=s.id AND w.id=%s ", + (order_id.shop_id.warehouse_id.id,)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id @@ -331,13 +337,13 @@ class add_product(osv.osv_memory): 'date':date_cur }) for line in order_id.lines: - key=('return%s') %line.id + key= 'return%s' % line.id if line.id: if data.has_key(key): - qty = data['return%s' %line.id] + qty = data[key] lines_obj.write(cr,uid,[line.id], { - 'qty_rfd':(line.qty or 0.0) + data['return%s' %line.id], - 'qty':line.qty-(data['return%s' %line.id] or 0.0) + 'qty_rfd':(line.qty or 0.0) + data[key], + 'qty':line.qty-(data[key] or 0.0) }) else: qty = line.qty @@ -349,7 +355,7 @@ class add_product(osv.osv_memory): 'location_id':location_id, 'product_id':line.product_id.id, 'location_dest_id':stock_dest_id, - 'name':'%s (return)' %order_id.name, + 'name':'%s (return)' % order_id.name, 'date':date_cur, 'date_planned':date_cur }) diff --git a/addons/stock/report/picking.rml b/addons/stock/report/picking.rml index 317180c7209..c2b46959e1d 100644 --- a/addons/stock/report/picking.rml +++ b/addons/stock/report/picking.rml @@ -181,7 +181,7 @@ [[ picking.origin or '']] - [[ (picking.address_id and picking.address_id.title) or '' ]] [[ (picking.address_id and and picking.address_id.name) or '' ]] + [[ (picking.address_id and picking.address_id.title) or '' ]] [[ (picking.address_id and picking.address_id.name) or '' ]] [[ formatLang(picking.min_date,date_time = True) ]] diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py index e72034e11d2..c95bd33ac32 100644 --- a/addons/survey/report/survey_analysis_report.py +++ b/addons/survey/report/survey_analysis_report.py @@ -189,9 +189,9 @@ class survey_analysis(report_rml): for ans in que.answer_choice_ids: rml += """""" + to_xml(tools.ustr(ans.answer)) + """""" - cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %d" % ans.id) + cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %s", (ans.id,)) tot_res = cr.fetchone()[0] - cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id = %d group by sra.column_id" % ans.id) + cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id=%s group by sra.column_id", (ans.id,)) calc_res = cr.dictfetchall() for mat_col in range(1, len(matrix_ans)): percantage = 0.0 @@ -210,7 +210,7 @@ class survey_analysis(report_rml): rml += """""" if que.is_comment_require: - cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id) + cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''",(que.id,)) tot_res = cr.fetchone()[0] rml += """""" + to_xml(tools.ustr(que.comment_label)) + """ """ + tools.ustr(tot_res) + """""" @@ -244,7 +244,7 @@ class survey_analysis(report_rml): if que.is_comment_require: # if que.make_comment_field: -# cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id) +# cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,)) # tot_res = cr.fetchone()[0] # tot_avg = 0.00 # if que.tot_resp: @@ -253,13 +253,13 @@ class survey_analysis(report_rml): # """ + str(tot_avg) + """% # """ + tools.ustr(tot_res) + """""" # else: - cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id) + cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,)) tot_res = cr.fetchone()[0] rml += """""" + to_xml(tools.ustr(que.comment_label)) + """ """ + tools.ustr(tot_res) + """""" elif que.type in['single_textbox']: - cr.execute("select count(id) from survey_response_line where question_id = %d and single_text!=''" % que.id) + cr.execute("select count(id) from survey_response_line where question_id = %s and single_text!=''",(que.id,)) rml += """ @@ -270,7 +270,7 @@ class survey_analysis(report_rml): """ elif que.type in['comment']: - cr.execute("select count(id) from survey_response_line where question_id = %d and comment !=''" % que.id) + cr.execute("select count(id) from survey_response_line where question_id = %s and comment !=''", (que.id,)) rml += """ @@ -303,12 +303,12 @@ class survey_analysis(report_rml): rating_weight_sum = 0 for mat_col in range(1, len(matrix_ans)): cr.execute("select count(sra.answer_id) from survey_response_line sr, survey_response_answer sra\ - where sr.id = sra.response_id and sra.answer_id = %d and sra.column_id ='%d'" % (ans.id,matrix_ans[mat_col][0])) + where sr.id = sra.response_id and sra.answer_id = %s and sra.column_id ='%s'", (ans.id,matrix_ans[mat_col][0])) tot_res = cr.fetchone()[0] cr.execute("select count(sra.answer_id),sqc.rating_weight from survey_response_line sr, survey_response_answer sra ,\ survey_question_column_heading sqc where sr.id = sra.response_id and \ - sqc.question_id = sr.question_id and sra.answer_id = %d and sqc.title ='%s'\ - group by sra.answer_id,sqc.rating_weight" % (ans.id,matrix_ans[mat_col][1])) + sqc.question_id = sr.question_id and sra.answer_id = %s and sqc.title ='%s'\ ++ group by sra.answer_id,sqc.rating_weight", (ans.id,matrix_ans[mat_col][1])) col_weight = cr.fetchone() if not col_weight: @@ -352,10 +352,10 @@ class survey_analysis(report_rml): rml += """""" + to_xml(tools.ustr(menu)) + """""" rml += """Answer Count""" cr.execute("select count(id), sra.answer_id from survey_response_answer sra \ - where sra.column_id='%s' group by sra.answer_id " % (column.id)) + where sra.column_id='%s' group by sra.answer_id ", (column.id,)) res_count = cr.dictfetchall() cr.execute("select count(sra.id),sra.value_choice, sra.answer_id, sra.column_id from survey_response_answer sra \ - where sra.column_id='%s' group by sra.value_choice ,sra.answer_id, sra.column_id" % (column.id)) + where sra.column_id='%s' group by sra.value_choice ,sra.answer_id, sra.column_id", (column.id,)) calc_percantage = cr.dictfetchall() for ans in que.answer_choice_ids: @@ -393,7 +393,7 @@ class survey_analysis(report_rml): Answer Count """ for ans in que.answer_choice_ids: - cr.execute("select answer from survey_response_answer where answer_id=%d group by answer" % ans.id) + cr.execute("select answer from survey_response_answer where answer_id=%s group by answer", (ans.id,)) tot_res = cr.dictfetchall() total = 0 for tot in tot_res: diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 4b44b6a1753..109f4509d81 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -108,7 +108,7 @@ class survey_question_wiz(osv.osv_memory): if sur_rec.state != "open" : raise osv.except_osv(_('Warning !'),_("You can not give answer because of survey is not open for answer")) cr.execute('select count(id) from survey_history where user_id=%s\ - and survey_id=%s' % (uid,survey_id)) + and survey_id=%s', (uid,survey_id)) res = cr.fetchone()[0] user_limit = survey_obj.browse(cr, uid, survey_id) user_limit = user_limit.response_user @@ -401,12 +401,12 @@ class survey_question_wiz(osv.osv_memory): address_id = user_obj.browse(cr, uid, uid).address_id.id if address_id: - cr.execute("select email from res_partner_address where id =%d" % address_id) + cr.execute("select email from res_partner_address where id =%s", (address_id,)) user_email = cr.fetchone()[0] resp_id = survey_data.responsible_id.address_id if resp_id: - cr.execute("select email from res_partner_address where id =%d" % resp_id.id) + cr.execute("select email from res_partner_address where id =%s", (resp_id.id,)) resp_email = cr.fetchone()[0] if user_email and resp_email: user_name = user_obj.browse(cr, uid, uid).name