From 1a0de2f0f97f247d62a3fff8516781618f7ea9f4 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 10 Dec 2008 15:29:55 +0100 Subject: [PATCH] [FIX] psycopg2: %d -> %s bzr revid: christophe@tinyerp.com-20081210142955-ewfr1qhzq9l1tjzn --- addons/account/account.py | 16 +++++----- addons/account/account_analytic_line.py | 2 +- addons/account/account_bank_statement.py | 8 ++--- addons/account/account_move_line.py | 24 +++++++------- addons/account/invoice.py | 14 ++++---- .../account/project/report/account_journal.py | 4 +-- .../account/project/report/analytic_check.py | 12 +++---- .../project/report/analytic_journal.py | 6 ++-- addons/account/project/report/cost_ledger.py | 8 ++--- .../report/inverted_analytic_balance.py | 2 +- .../project/report/quantity_cost_ledger.py | 12 +++---- addons/account/report/account_balance.py | 4 +-- addons/account/report/account_journal.py | 12 +++---- addons/account/report/aged_trial_balance.py | 18 +++++------ addons/account/report/central_journal.py | 8 ++--- addons/account/report/general_journal.py | 12 +++---- addons/account/report/general_ledger.py | 12 +++---- .../report/general_ledger_landscape.py | 12 +++---- addons/account/report/partner_balance.py | 2 +- addons/account/report/tax_report.py | 8 ++--- addons/account/report/third_party_ledger.py | 18 +++++------ .../wizard/wizard_automatic_reconcile.py | 20 ++++++------ .../account/wizard/wizard_bank_reconcile.py | 2 +- .../account/wizard/wizard_fiscalyear_close.py | 16 +++++----- .../account/wizard/wizard_journal_select.py | 2 +- .../wizard/wizard_open_closed_fiscalyear.py | 6 ++-- addons/account/wizard/wizard_period_close.py | 4 +-- addons/account_budget/crossovered_budget.py | 2 +- addons/account_budget/report/budget_report.py | 2 +- .../wizard/wizard_followup_print.py | 6 ++-- .../report/report_account_invoice_layout.py | 4 +-- .../report/special_message_invoice.py | 4 +-- addons/account_voucher/voucher.py | 8 ++--- addons/auction/auction.py | 10 +++--- addons/auction/report/auction_total_rml.py | 32 +++++++++---------- addons/auction/report/buyer_list.py | 6 ++-- addons/board/board.py | 2 +- addons/crm/crm_operators.py | 2 +- addons/crm/crm_segmentation.py | 14 ++++---- addons/crm_profiling/crm_profiling.py | 18 +++++------ addons/document/document.py | 6 ++-- addons/document/ftpserver/abstracted_fs.py | 2 +- addons/event/wizard/event_registration.py | 2 +- addons/event_project/wizard/event_task.py | 2 +- addons/hr/hr.py | 2 +- addons/hr_attendance/hr_attendance.py | 2 +- .../hr_attendance/report/attendance_errors.py | 4 +-- .../report/holidays_summary_report.py | 2 +- addons/hr_timesheet/report/user_timesheet.py | 4 +-- addons/hr_timesheet/report/users_timesheet.py | 4 +-- addons/hr_timesheet/wizard/sign_in_out.py | 4 +-- .../report/account_analytic_profit.py | 2 +- .../report/cost_ledger.py | 10 +++--- .../hr_timesheet_final_invoice_create.py | 8 ++--- .../wizard/hr_timesheet_invoice_create.py | 7 ++-- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 4 +-- addons/l10n_be/wizard/partner_vat_listing.py | 2 +- addons/membership/membership.py | 8 ++--- addons/mrp/mrp.py | 18 +++++------ addons/mrp/report/workcenter_load.py | 2 +- addons/mrp/schedulers.py | 2 +- addons/point_of_sale/report/pos_receipt.py | 8 ++--- addons/product/pricelist.py | 20 ++++++------ addons/project/project.py | 14 ++++---- addons/purchase/purchase.py | 2 +- addons/purchase/report/order.py | 6 ++-- .../report_analytic_planning.py | 10 +++--- addons/sale/report/shipping.py | 8 ++--- addons/scrum/report/sprint_burndown.py | 4 +-- addons/stock/product.py | 4 +-- addons/stock/stock.py | 14 ++++---- addons/stock/wizard/inventory_merge_zero.py | 4 +-- 72 files changed, 282 insertions(+), 283 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 30a18ac6efe..4e239d12cc9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -606,8 +606,8 @@ class account_period(osv.osv): if role.name=='Period': mode = 'draft' for id in ids: - cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id)) - cr.execute('update account_period set state=%s where id=%d', (mode, id)) + cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) + cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True account_period() @@ -637,7 +637,7 @@ class account_journal_period(osv.osv): def _check(self, cr, uid, ids, context={}): for obj in self.browse(cr, uid, ids, context): - cr.execute('select * from account_move_line where journal_id=%d and period_id=%d limit 1', (obj.journal_id.id, obj.period_id.id)) + cr.execute('select * from account_move_line where journal_id=%s and period_id=%s limit 1', (obj.journal_id.id, obj.period_id.id)) res = cr.fetchall() if res: raise osv.except_osv(_('Error !'), _('You can not modify/delete a journal with entries for this period !')) @@ -882,7 +882,7 @@ class account_move(osv.osv): # find the first line of this move with the current mode # or create it if it doesn't exist - cr.execute('select id from account_move_line where move_id=%d and centralisation=%s limit 1', (move.id, mode)) + cr.execute('select id from account_move_line where move_id=%s and centralisation=%s limit 1', (move.id, mode)) res = cr.fetchone() if res: line_id = res[0] @@ -901,16 +901,16 @@ class account_move(osv.osv): # find the first line of this move with the other mode # so that we can exclude it from our calculation - cr.execute('select id from account_move_line where move_id=%d and centralisation=%s limit 1', (move.id, mode2)) + cr.execute('select id from account_move_line where move_id=%s and centralisation=%s limit 1', (move.id, mode2)) res = cr.fetchone() if res: line_id2 = res[0] else: line_id2 = 0 - cr.execute('select sum('+mode+') from account_move_line where move_id=%d and id<>%d', (move.id, line_id2)) + cr.execute('select sum('+mode+') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2)) result = cr.fetchone()[0] or 0.0 - cr.execute('update account_move_line set '+mode2+'=%f where id=%d', (result, line_id)) + cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id)) return True # @@ -1625,7 +1625,7 @@ class account_config_wizard(osv.osv_memory): mod_obj.write(cr , uid, [id] ,{'state' : 'to install'}) mod_obj.download(cr, uid, [id], context=context) cr.commit() - cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(id,)) + cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%s and m.state='uninstalled'",(id,)) ret = cr.fetchall() if len(ret): for r in ret: diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index 7981bac255e..603b77bc36b 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -82,7 +82,7 @@ class account_analytic_line(osv.osv): def view_header_get(self, cr, user, view_id, view_type, context): if context.get('account_id', False): - cr.execute('select name from account_analytic_account where id=%d', (context['account_id'],)) + cr.execute('select name from account_analytic_account where id=%s', (context['account_id'],)) res = cr.fetchone() res = _('Entries: ')+ (res[0] or '') return res diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index a1d47dd027d..69afa0987fe 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -37,7 +37,7 @@ class account_bank_statement(osv.osv): return False def _default_balance_start(self, cr, uid, context={}): - cr.execute('select id from account_bank_statement where journal_id=%d order by date desc limit 1', (1,)) + cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,)) res = cr.fetchone() if res: return self.browse(cr, uid, [res[0]], context)[0].balance_end @@ -313,7 +313,7 @@ class account_bank_statement(osv.osv): cursor.execute('SELECT balance_end_real \ FROM account_bank_statement \ - WHERE journal_id = %d \ + WHERE journal_id = %s \ ORDER BY date DESC,id DESC LIMIT 1', (journal_id,)) res = cursor.fetchone() balance_start = res and res[0] or 0.0 @@ -513,8 +513,8 @@ class account_bank_statement_line(osv.osv): cursor.execute('SELECT sum(debit-credit) \ FROM account_move_line \ WHERE (reconcile_id is null) \ - AND partner_id = %d \ - AND account_id=%d', (partner_id, account_id)) + AND partner_id = %s \ + AND account_id=%s', (partner_id, account_id)) res = cursor.fetchone() balance = res and res[0] or 0.0 diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 19dac4949b0..d32e2c7b003 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -133,7 +133,7 @@ class account_move_line(osv.osv): from \ account_move_line \ where \ - journal_id=%d and period_id=%d and create_uid=%d and state=%s \ + journal_id=%s and period_id=%s and create_uid=%s and state=%s \ order by id desc limit 1', (context['journal_id'], context['period_id'], uid, 'draft')) res = cr.fetchone() @@ -148,7 +148,7 @@ class account_move_line(osv.osv): from \ account_move_line \ where \ - journal_id=%d and period_id=%d and create_uid=%d \ + journal_id=%s and period_id=%s and create_uid=%s \ order by id desc', (context['journal_id'], context['period_id'], uid)) res = cr.fetchone() @@ -216,9 +216,9 @@ class account_move_line(osv.osv): res={} # TODO group the foreach in sql for id in ids: - cr.execute('SELECT date,account_id FROM account_move_line WHERE id=%d', (id,)) + cr.execute('SELECT date,account_id FROM account_move_line WHERE id=%s', (id,)) dt, acc = cr.fetchone() - cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%d AND (date<%s OR (date=%s AND id<=%d))', (acc,dt,dt,id)) + cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%s AND (date<%s OR (date=%s AND id<=%s))', (acc,dt,dt,id)) res[id] = cr.fetchone()[0] return res @@ -281,11 +281,11 @@ class account_move_line(osv.osv): elif (x[2] is False) and (x[1] == '<>' or x[1] == '!='): qu1.append('(i.id IS NOT NULL)') else: - qu1.append('(i.id %s %s)' % (x[1], '%d')) + qu1.append('(i.id %s %s)' % (x[1], '%s')) qu2.append(x[2]) elif x[1] == 'in': if len(x[2]) > 0: - qu1.append('(i.id in (%s))' % (','.join(['%d'] * len(x[2])))) + qu1.append('(i.id in (%s))' % (','.join(['%s'] * len(x[2])))) qu2 += x[2] else: qu1.append(' (False)') @@ -347,7 +347,7 @@ class account_move_line(osv.osv): dt = time.strftime('%Y-%m-%d') if ('journal_id' in context) and ('period_id' in context): cr.execute('select date from account_move_line ' \ - 'where journal_id=%d and period_id=%d ' \ + 'where journal_id=%s and period_id=%s ' \ 'order by id desc limit 1', (context['journal_id'], context['period_id'])) res = cr.fetchone() @@ -615,15 +615,15 @@ class account_move_line(osv.osv): def view_header_get(self, cr, user, view_id, view_type, context): if context.get('account_id', False): - cr.execute('select code from account_account where id=%d', (context['account_id'],)) + cr.execute('select code from account_account where id=%s', (context['account_id'],)) res = cr.fetchone() res = _('Entries: ')+ (res[0] or '') return res if (not context.get('journal_id', False)) or (not context.get('period_id', False)): return False - cr.execute('select code from account_journal where id=%d', (context['journal_id'],)) + cr.execute('select code from account_journal where id=%s', (context['journal_id'],)) j = cr.fetchone()[0] or '' - cr.execute('select code from account_period where id=%d', (context['period_id'],)) + cr.execute('select code from account_period where id=%s', (context['period_id'],)) p = cr.fetchone()[0] or '' if j or p: return j+(p and (':'+p) or '') @@ -716,7 +716,7 @@ class account_move_line(osv.osv): return result def _update_journal_check(self, cr, uid, journal_id, period_id, context={}): - cr.execute('select state from account_journal_period where journal_id=%d and period_id=%d', (journal_id, period_id)) + cr.execute('select state from account_journal_period where journal_id=%s and period_id=%s', (journal_id, period_id)) result = cr.fetchall() for (state,) in result: if state=='done': @@ -767,7 +767,7 @@ class account_move_line(osv.osv): if not move_id: if journal.centralisation: # use the first move ever created for this journal and period - cr.execute('select id, state, name from account_move where journal_id=%d and period_id=%d order by id limit 1', (context['journal_id'],context['period_id'])) + cr.execute('select id, state, name from account_move where journal_id=%s and period_id=%s order by id limit 1', (context['journal_id'],context['period_id'])) res = cr.fetchone() if res: if res[1] != 'draft': diff --git a/addons/account/invoice.py b/addons/account/invoice.py index c57626d5720..b2ff173b80b 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -371,14 +371,14 @@ class account_invoice(osv.osv): return False ok = True for id in res: - cr.execute('select reconcile_id from account_move_line where id=%d', (id,)) + cr.execute('select reconcile_id from account_move_line where id=%s', (id,)) ok = ok and bool(cr.fetchone()[0]) return ok def button_reset_taxes(self, cr, uid, ids, context={}): ait_obj = self.pool.get('account.invoice.tax') for id in ids: - cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%d", (id,)) + cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) for taxe in ait_obj.compute(cr, uid, id).values(): ait_obj.create(cr, uid, taxe) return True @@ -664,13 +664,13 @@ class account_invoice(osv.osv): else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ - 'WHERE id=%d', (number, id)) + 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ - 'WHERE move_id=%d AND (ref is null OR ref = \'\')', + 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ - 'WHERE account_move_line.move_id = %d ' \ + 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True @@ -705,7 +705,7 @@ class account_invoice(osv.osv): for inv in invs: part=inv['partner_id'] and inv['partner_id'][0] pc = pr = 0.0 - cr.execute('select sum(quantity*price_unit) from account_invoice_line where invoice_id=%d', (inv['id'],)) + cr.execute('select sum(quantity*price_unit) from account_invoice_line where invoice_id=%s', (inv['id'],)) total = inv['amount_untaxed'] if inv['type'] in ('in_invoice','in_refund'): partnertype='supplier' @@ -1115,7 +1115,7 @@ class account_invoice_tax(osv.osv): def move_line_get(self, cr, uid, invoice_id): res = [] - cr.execute('SELECT * FROM account_invoice_tax WHERE invoice_id=%d', (invoice_id,)) + cr.execute('SELECT * FROM account_invoice_tax WHERE invoice_id=%s', (invoice_id,)) for t in cr.dictfetchall(): if not t['amount'] \ and not t['tax_code_id'] \ diff --git a/addons/account/project/report/account_journal.py b/addons/account/project/report/account_journal.py index 77530e1a06b..d305547aa91 100644 --- a/addons/account/project/report/account_journal.py +++ b/addons/account/project/report/account_journal.py @@ -29,12 +29,12 @@ from report import report_sxw # class journal_print(report_sxw.rml_parse): def lines(self, journal_id, *args): - self.cr.execute('select id from account_analytic_line where journal_id=%d order by date,id', (journal_id,)) + self.cr.execute('select id from account_analytic_line where journal_id=%s order by date,id', (journal_id,)) ids = map(lambda x: x[0], self.cr.fetchall()) res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) return res def _sum_lines(self, journal_id): - self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%d', (journal_id,)) + self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%s', (journal_id,)) return self.cr.fetchone()[0] or 0.0 def __init__(self, cr, uid, name, context): super(journal_print, self).__init__(cr, uid, name, context) diff --git a/addons/account/project/report/analytic_check.py b/addons/account/project/report/analytic_check.py index 73df2b693cc..0c8a3b43cd3 100644 --- a/addons/account/project/report/analytic_check.py +++ b/addons/account/project/report/analytic_check.py @@ -49,19 +49,19 @@ class account_analytic_analytic_check(report_sxw.rml_parse): for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code']): self.cr.execute("SELECT sum(debit), sum(credit) \ FROM account_move_line \ - WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %d", (date1, date2, a['id'])) + WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %s", (date1, date2, a['id'])) (gd, gc) = self.cr.fetchone() gd = gd or 0.0 gc = gc or 0.0 self.cr.execute("SELECT abs(sum(amount)) AS balance \ FROM account_analytic_line \ - WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %d", (date1, date2, a['id'])) + WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %s", (date1, date2, a['id'])) (ad,) = self.cr.fetchone() ad = ad or 0.0 self.cr.execute("SELECT abs(sum(amount)) AS balance \ FROM account_analytic_line \ - WHERE date>=%s AND date<=%s AND amount<0 AND general_account_id = %d", (date1, date2, a['id'])) + WHERE date>=%s AND date<=%s AND amount<0 AND general_account_id = %s", (date1, date2, a['id'])) (ac,) = self.cr.fetchone() ac = ac or 0.0 @@ -85,19 +85,19 @@ class account_analytic_analytic_check(report_sxw.rml_parse): # for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','sign']): # self.cr.execute("SELECT sum(debit), sum(credit) \ # FROM account_move_line \ -# WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %d", (date1, date2, a['id'])) +# WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %s", (date1, date2, a['id'])) # (gd, gc) = self.cr.fetchone() # gd = gd or 0.0 # gc = gc or 0.0 # # self.cr.execute("SELECT abs(sum(amount)) AS balance \ # FROM account_analytic_line \ -# WHERE date>=%s AND date<=%s AND amount*%d>0 AND general_account_id = %d", (date1, date2, a['sign'], a['id'])) +# WHERE date>=%s AND date<=%s AND amount*%s>0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) # (ad,) = self.cr.fetchone() # ad = ad or 0.0 # self.cr.execute("SELECT abs(sum(amount)) AS balance \ # FROM account_analytic_line \ -# WHERE date>=%s AND date<=%s AND amount*%d<0 AND general_account_id = %d", (date1, date2, a['sign'], a['id'])) +# WHERE date>=%s AND date<=%s AND amount*%s<0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) # (ac,) = self.cr.fetchone() # ac = ac or 0.0 # diff --git a/addons/account/project/report/analytic_journal.py b/addons/account/project/report/analytic_journal.py index 4f2a116c10a..659852d3c2b 100644 --- a/addons/account/project/report/analytic_journal.py +++ b/addons/account/project/report/analytic_journal.py @@ -38,7 +38,7 @@ class account_analytic_journal(report_sxw.rml_parse): }) def _lines(self, journal_id, date1, date2): - self.cr.execute('SELECT DISTINCT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null)', (date1, date2, journal_id,)) + self.cr.execute('SELECT DISTINCT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%s) AND (move_id is not null)', (date1, date2, journal_id,)) ids = map(lambda x: x[0], self.cr.fetchall()) return self.pool.get('account.move.line').browse(self.cr, self.uid, ids) @@ -49,11 +49,11 @@ class account_analytic_journal(report_sxw.rml_parse): return self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) def _sum_general(self, journal_id, date1, date2): - self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null))', (date1, date2, journal_id,)) + self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%s) AND (move_id is not null))', (date1, date2, journal_id,)) return self.cr.fetchall()[0][0] or 0 def _sum_analytic(self, journal_id, date1, date2): - self.cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND journal_id=%d", (date1, date2, journal_id)) + self.cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND journal_id=%s", (date1, date2, journal_id)) res = self.cr.dictfetchone() return res['sum'] or 0 diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 63acbc36e91..5cf7b89564c 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -42,7 +42,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _lines_g(self, account_id, date1, date2): self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2)) res = self.cr.dictfetchall() @@ -60,7 +60,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _lines_a(self, general_account_id, account_id, date1, date2): self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2)) res = self.cr.dictfetchall() @@ -78,11 +78,11 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _account_sum_debit(self, account_id, date1, date2): - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_credit(self, account_id, date1, date2): - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_balance(self, account_id, date1, date2): diff --git a/addons/account/project/report/inverted_analytic_balance.py b/addons/account/project/report/inverted_analytic_balance.py index 22b2a37e81a..834c38232ff 100644 --- a/addons/account/project/report/inverted_analytic_balance.py +++ b/addons/account/project/report/inverted_analytic_balance.py @@ -61,7 +61,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \ FROM account_analytic_line AS aal, account_analytic_account AS aaa \ - WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%d AND aal.date>=%s AND aal.date<=%s \ + WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (general_account_id, date1, date2)) res = self.cr.dictfetchall() diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index a97d30040fe..0d6241fa30f 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -41,7 +41,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \ aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%d) AND (aal.date>=%s) \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) \ AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ AND aa.active \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", @@ -51,7 +51,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \ aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%d) AND (aal.date>=%s) \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) \ AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ AND aa.active \ AND (aal.journal_id IN (" + @@ -68,7 +68,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): aaj.code AS cj \ FROM account_analytic_line AS aal, \ account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ ORDER BY aal.date, aaj.code, aal.code", @@ -80,7 +80,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): aaj.code AS cj \ FROM account_analytic_line AS aal, \ account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) AND (aaj.id IN (" + ','.join(map(str, journal_ids)) + ")) \ @@ -93,13 +93,13 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): if not journals or not journals[0][2]: self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id=%d AND date>=%s AND date<=%s", + WHERE account_id=%s AND date>=%s AND date<=%s", (account_id, date1, date2)) else: journal_ids = journals[0][2] self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id = %d AND date >= %s AND date <= %s \ + WHERE account_id = %s AND date >= %s AND date <= %s \ AND journal_id IN (" + ','.join(map(str, journal_ids)) + ")", (account_id, date1, date2)) diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index a0aef896250..85596741a3c 100755 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -52,7 +52,7 @@ class account_balance(report_sxw.rml_parse): fisc_id = form['fiscalyear'] if not (fisc_id): return '' - self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id))) + self.cr.execute("select name from account_fiscalyear where id = %s" , (int(fisc_id),)) res=self.cr.fetchone() return res and res[0] or '' @@ -226,4 +226,4 @@ class account_balance(report_sxw.rml_parse): def _sum_debit(self): return self.sum_debit -report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=False) \ No newline at end of file +report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=False) diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 38e410ca70d..06898020f08 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -44,9 +44,9 @@ class journal_print(report_sxw.rml_parse): for period in period_id: ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) if ids_journal_period: - self.cr.execute('update account_journal_period set state=%s where journal_id=%d and period_id=%d and state=%s', ('printed',journal,period,'draft')) + self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal,period,'draft')) self.cr.commit() - self.cr.execute('select id from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\' order by ('+ sort_selection +'),id', (period, journal)) + self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by ('+ sort_selection +'),id', (period, journal)) ids = map(lambda x: x[0], self.cr.fetchall()) ids_final.append(ids) line_ids = [] @@ -54,18 +54,18 @@ class journal_print(report_sxw.rml_parse): a = self.pool.get('account.move.line').browse(self.cr, self.uid, line_id ) line_ids.append(a) return line_ids - self.cr.execute('update account_journal_period set state=%s where journal_id=%d and period_id=%d and state=%s', ('printed',journal_id,period_id,'draft')) + self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() - self.cr.execute('select id from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\' order by date,id', (period_id, journal_id)) + self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by date,id', (period_id, journal_id)) ids = map(lambda x: x[0], self.cr.fetchall()) return self.pool.get('account.move.line').browse(self.cr, self.uid, ids ) def _sum_debit(self, period_id, journal_id): - self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, period_id, journal_id): - self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print,header=False) report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print,header=False) diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index 8ffdb1b566b..0688c2a2274 100755 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -66,7 +66,7 @@ class aged_trial_report(rml_parse.rml_parse): "AND ((reconcile_id IS NULL) " \ "OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \ "AND (line.partner_id=res_partner.id) " \ - "AND (account_account.company_id = %d) " \ + "AND (account_account.company_id = %s) " \ "ORDER BY res_partner.name", (form['date1'],form['company_id'])) partners = self.cr.dictfetchall() ## mise a 0 du total @@ -82,10 +82,10 @@ class aged_trial_report(rml_parse.rml_parse): "FROM account_move_line AS line, account_account " \ "WHERE (line.account_id=account_account.id) " \ "AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \ - "AND (COALESCE(date_maturity,date) < %s) AND (partner_id=%d) " \ + "AND (COALESCE(date_maturity,date) < %s) AND (partner_id=%s) " \ "AND ((reconcile_id IS NULL) " \ "OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \ - "AND (account_account.company_id = %d) " \ + "AND (account_account.company_id = %s) " \ "AND account_account.active", (form['date1'], partner['id'],form['date1'], form['company_id'])) before = self.cr.fetchone() @@ -98,10 +98,10 @@ class aged_trial_report(rml_parse.rml_parse): "FROM account_move_line AS line, account_account " \ "WHERE (line.account_id=account_account.id) " \ "AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \ - "AND (COALESCE(date_maturity,date) > %s) AND (partner_id=%d) " \ + "AND (COALESCE(date_maturity,date) > %s) AND (partner_id=%s) " \ "AND ((reconcile_id IS NULL) " \ "OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \ - "AND (account_account.company_id = %d) " \ + "AND (account_account.company_id = %s) " \ "AND account_account.active", (form['date1'], partner['id'],form['date1'], form['company_id'])) after = self.cr.fetchone() @@ -113,10 +113,10 @@ class aged_trial_report(rml_parse.rml_parse): "WHERE (line.account_id=account_account.id) " \ "AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \ "AND (COALESCE(date_maturity,date) BETWEEN %s AND %s) " \ - "AND (partner_id = %d) " \ + "AND (partner_id = %s) " \ "AND ((reconcile_id IS NULL) " \ "OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \ - "AND (account_account.company_id = %d) " \ + "AND (account_account.company_id = %s) " \ "AND account_account.active", (form[str(i)]['start'], form[str(i)]['stop'],partner['id'],form['date1'] ,form['company_id'])) during = self.cr.fetchone() @@ -127,10 +127,10 @@ class aged_trial_report(rml_parse.rml_parse): "FROM account_move_line AS line, account_account " \ "WHERE (line.account_id = account_account.id) " \ "AND (account_account.type IN " + self.ACCOUNT_TYPE + ") " \ - "AND (partner_id = %d) " \ + "AND (partner_id = %s) " \ "AND ((reconcile_id IS NULL) " \ "OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \ - "AND (account_account.company_id = %d) " \ + "AND (account_account.company_id = %s) " \ "AND account_account.active", (partner['id'],form['date1'],form['company_id'])) total = self.cr.fetchone() diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py index 8b8932782b6..5ce24cef8be 100644 --- a/addons/account/report/central_journal.py +++ b/addons/account/report/central_journal.py @@ -43,22 +43,22 @@ class journal_print(report_sxw.rml_parse): for period in period_id: ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) if ids_journal_period: - self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal)) + self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%s and l.journal_id=%s and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal)) res = self.cr.dictfetchall() a = {'journal':self.pool.get('account.journal').browse(self.cr, self.uid, journal),'period':self.pool.get('account.period').browse(self.cr, self.uid, period)} res[0].update(a) ids_final.append(res) return ids_final - self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id)) + self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%s and l.journal_id=%s and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id)) res = self.cr.dictfetchall() return res def _sum_debit(self, period_id, journal_id): - self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, period_id, journal_id): - self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print, header=False) report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml',parser=journal_print, header=False) diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 6894ccdc81c..0499fc064fb 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -75,7 +75,7 @@ class journal_print(report_sxw.rml_parse): periods.append(data.period_id.id) for period in periods: period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%d and journal_id in (' + ','.join(map(str, journal_id)) + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period,)) res = self.cr.dictfetchall() res[0].update({'period_name':period_data.name}) res[0].update({'pid':period}) @@ -83,27 +83,27 @@ class journal_print(report_sxw.rml_parse): return lines_data if not self.journal_ids: return [] - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%d and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,)) res = self.cr.dictfetchall() return res def _sum_debit_period(self, period_id,journal_id=None): if type(journal_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit_period(self, period_id,journal_id=None): if type(journal_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) return self.cr.fetchone()[0] or 0.0 def _sum_debit(self,period_id=None,journal_id=None): diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index aef67140939..64ee26229f8 100755 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -289,13 +289,13 @@ class general_ledger(rml_parse.rml_parse): FROM account_move_line as l LEFT JOIN res_currency c on (l.currency_id=c.id) JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %d + AND account_id = %%s AND %s - WHERE l.date<='%s' - AND l.date>='%s' - ORDER by %s"""%(account.id,self.query,self.date_borne['max_date'],self.date_borne['min_date'],sorttag) + WHERE l.date<=%%s + AND l.date>=%%s + ORDER by %s""" % (self.query, sorttag) - self.cr.execute(sql) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) res = self.cr.dictfetchall() @@ -415,7 +415,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %d "%account.id) + self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index 6fd2eafae76..4dc1060ab1e 100755 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -273,13 +273,13 @@ class general_ledger_landscape(rml_parse.rml_parse): FROM account_move_line as l LEFT JOIN res_currency c on (l.currency_id=c.id) JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %d + AND account_id = %%s AND %s - WHERE l.date<='%s' - AND l.date>='%s' - ORDER by %s"""%(account.id,self.query,self.date_borne['max_date'],self.date_borne['min_date'],sorttag) + WHERE l.date<=%%s + AND l.date>=%%s + ORDER by %s""" % (self.query, sorttag) - self.cr.execute(sql) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) res = self.cr.dictfetchall() sum = 0.0 @@ -395,7 +395,7 @@ class general_ledger_landscape(rml_parse.rml_parse): def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %d "%account.id) + self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 0e286d61805..2ced211b503 100644 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -191,7 +191,7 @@ class partner_balance(report_sxw.rml_parse): "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type = t.code) " \ - "WHERE a.company_id = %d " \ + "WHERE a.company_id = %s " \ "AND a.type IN " + self.ACCOUNT_TYPE + " " \ "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py index 50d85247351..e5ed33d84b8 100755 --- a/addons/account/report/tax_report.py +++ b/addons/account/report/tax_report.py @@ -111,9 +111,9 @@ class tax_report(rml_parse.rml_parse): LEFT JOIN account_invoice invoice ON \ (invoice.move_id = move.id) \ WHERE line.state<>%s \ - AND line.tax_code_id = %d \ + AND line.tax_code_id = %s \ AND line.account_id = account.id \ - AND account.company_id = %d \ + AND account.company_id = %s \ AND move.id = line.move_id \ AND ((invoice.state = %s) \ OR (invoice.id IS NULL)) \ @@ -131,9 +131,9 @@ class tax_report(rml_parse.rml_parse): FROM account_move_line AS line, \ account_account AS account \ WHERE line.state <> %s \ - AND line.tax_code_id = %d \ + AND line.tax_code_id = %s \ AND line.account_id = account.id \ - AND account.company_id = %d \ + AND account.company_id = %s \ AND account.active \ GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, company_id)) diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 5c8132082d9..7fb908e2053 100755 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -175,7 +175,7 @@ class third_party_ledger(rml_parse.rml_parse): "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type=t.code) " \ - "WHERE a.company_id = %d " \ + "WHERE a.company_id = %s " \ 'AND a.type IN ' + self.ACCOUNT_TYPE + " " \ "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) @@ -195,7 +195,7 @@ class third_party_ledger(rml_parse.rml_parse): "AND line.reconcile_id IS NULL " \ "AND line.account_id IN (" + self.account_ids + ") " \ " " + PARTNER_REQUEST + " " \ - "AND account.company_id = %d " \ + "AND account.company_id = %s " \ "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id'])) # else: @@ -208,7 +208,7 @@ class third_party_ledger(rml_parse.rml_parse): # "AND line.date IN (" + self.date_lst_string + ") " \ # "AND line.account_id IN (" + self.account_ids + ") " \ # " " + PARTNER_REQUEST + " " \ -# "AND account.company_id = %d " \ +# "AND account.company_id = %s " \ # "AND account.active " , # (data['form']['company_id'])) @@ -236,7 +236,7 @@ class third_party_ledger(rml_parse.rml_parse): # "FROM account_move_line l " \ # "LEFT JOIN account_journal j " \ # "ON (l.journal_id = j.id) " \ -# "WHERE l.partner_id = %d " \ +# "WHERE l.partner_id = %s " \ # "AND l.account_id IN (" + self.account_ids + ") " \ # "AND l.date <= %s " \ # "AND l.reconcile_id IS NULL " @@ -255,7 +255,7 @@ class third_party_ledger(rml_parse.rml_parse): "FROM account_move_line l " \ "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ - "WHERE l.partner_id = %d " \ + "WHERE l.partner_id = %s " \ "AND l.account_id IN (" + self.account_ids + ") " \ "AND l.date IN (" + self.date_lst_string + ") " \ " " + RECONCILE_TAG + " "\ @@ -283,7 +283,7 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id = %d " \ + "WHERE partner_id = %s " \ "AND account_id IN (" + self.account_ids + ") " \ "AND reconcile_id IS NULL " \ "AND date < %s " , @@ -298,7 +298,7 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id = %d " \ + "WHERE partner_id = %s " \ "AND account_id IN (" + self.account_ids + ") " \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , @@ -322,7 +322,7 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id=%d " \ + "WHERE partner_id=%s " \ "AND account_id IN (" + self.account_ids + ") " \ "AND reconcile_id IS NULL " \ "AND date < %s " , @@ -336,7 +336,7 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id=%d " \ + "WHERE partner_id=%s " \ "AND account_id IN (" + self.account_ids + ") " \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , diff --git a/addons/account/wizard/wizard_automatic_reconcile.py b/addons/account/wizard/wizard_automatic_reconcile.py index df191fb91b2..7c04c963552 100644 --- a/addons/account/wizard/wizard_automatic_reconcile.py +++ b/addons/account/wizard/wizard_automatic_reconcile.py @@ -226,11 +226,11 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT partner_id " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ + "WHERE account_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ "GROUP BY partner_id " \ - "HAVING ABS(SUM(debit-credit)) < %f AND count(*)>0", + "HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0", (account_id, max_amount)) partner_ids = [id for (id,) in cr.fetchall()] @@ -238,8 +238,8 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT id " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ - "AND partner_id=%d " \ + "WHERE account_id=%s " \ + "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) @@ -253,7 +253,7 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT partner_id " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ + "WHERE account_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ "AND partner_id IS NOT NULL " \ @@ -267,8 +267,8 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT id, debit " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ - "AND partner_id=%d " \ + "WHERE account_id=%s " \ + "AND partner_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ "AND debit > 0", @@ -279,8 +279,8 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT id, credit " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ - "AND partner_id=%d " \ + "WHERE account_id=%s " \ + "AND partner_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " \ "AND credit > 0", @@ -297,7 +297,7 @@ def _reconcile(self, cr, uid, data, context): cr.execute( "SELECT count(*) " \ "FROM account_move_line " \ - "WHERE account_id=%d " \ + "WHERE account_id=%s " \ "AND reconcile_id IS NULL " \ "AND state <> 'draft' " + partner_filter, (account_id,)) diff --git a/addons/account/wizard/wizard_bank_reconcile.py b/addons/account/wizard/wizard_bank_reconcile.py index 0c80ed5a7fb..2fc1bd63c61 100644 --- a/addons/account/wizard/wizard_bank_reconcile.py +++ b/addons/account/wizard/wizard_bank_reconcile.py @@ -34,7 +34,7 @@ _journal_fields = { def _action_open_window(self, cr, uid, data, context): form = data['form'] - cr.execute('select default_credit_account_id from account_journal where id=%d', (form['journal_id'],)) + cr.execute('select default_credit_account_id from account_journal where id=%s', (form['journal_id'],)) account_id = cr.fetchone()[0] if not account_id: raise Exception, _('You have to define the bank account\nin the journal definition for reconciliation.') diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 250f2363d3b..f6f47a1d1ae 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -106,11 +106,11 @@ def _data_save(self, cr, uid, data, context): 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ - 'WHERE account_id = %d ' \ + 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'AND reconcile_id is NULL ' \ 'ORDER BY id ' \ - 'LIMIT %d OFFSET %d', (account.id, limit, offset)) + 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break @@ -136,10 +136,10 @@ def _data_save(self, cr, uid, data, context): 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ - 'WHERE account_id = %d ' \ + 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ - 'LIMIT %d OFFSET %d', (account.id,fy_id, limit, offset)) + 'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset)) result = cr.dictfetchall() if not result: break @@ -157,13 +157,13 @@ def _data_save(self, cr, uid, data, context): cr.execute('UPDATE account_journal_period ' \ 'SET state = %s ' \ - 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)', + 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', ('done',fy_id)) cr.execute('UPDATE account_period SET state = %s ' \ - 'WHERE fiscalyear_id = %d', ('done',fy_id)) + 'WHERE fiscalyear_id = %s', ('done',fy_id)) cr.execute('UPDATE account_fiscalyear ' \ - 'SET state = %s, end_journal_period_id = %d' \ - 'WHERE id = %d', ('done',start_jp,fy_id)) + 'SET state = %s, end_journal_period_id = %s' \ + 'WHERE id = %s', ('done',start_jp,fy_id)) return {} class wiz_journal_close(wizard.interface): diff --git a/addons/account/wizard/wizard_journal_select.py b/addons/account/wizard/wizard_journal_select.py index 0bc9b7dc5ad..74f4a597a1e 100644 --- a/addons/account/wizard/wizard_journal_select.py +++ b/addons/account/wizard/wizard_journal_select.py @@ -31,7 +31,7 @@ def _action_open_window(self, cr, uid, data, context): id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] result = act_obj.read(cr, uid, [id])[0] - cr.execute('select journal_id,period_id from account_journal_period where id=%d', (data['id'],)) + cr.execute('select journal_id,period_id from account_journal_period where id=%s', (data['id'],)) journal_id,period_id = cr.fetchone() result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]) diff --git a/addons/account/wizard/wizard_open_closed_fiscalyear.py b/addons/account/wizard/wizard_open_closed_fiscalyear.py index 5f284b3a7ba..ca484cf03ba 100644 --- a/addons/account/wizard/wizard_open_closed_fiscalyear.py +++ b/addons/account/wizard/wizard_open_closed_fiscalyear.py @@ -47,13 +47,13 @@ def _remove_entries(self, cr, uid, data, context): pool.get('account.move').unlink(cr,uid,ids_move) cr.execute('UPDATE account_journal_period ' \ 'SET state = %s ' \ - 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)', + 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', ('draft',data_fyear)) cr.execute('UPDATE account_period SET state = %s ' \ - 'WHERE fiscalyear_id = %d', ('draft',data_fyear)) + 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) cr.execute('UPDATE account_fiscalyear ' \ 'SET state = %s, end_journal_period_id = null '\ - 'WHERE id = %d', ('draft',data_fyear)) + 'WHERE id = %s', ('draft',data_fyear)) return {} class open_closed_fiscal(wizard.interface): diff --git a/addons/account/wizard/wizard_period_close.py b/addons/account/wizard/wizard_period_close.py index 589043a8821..297b271e423 100644 --- a/addons/account/wizard/wizard_period_close.py +++ b/addons/account/wizard/wizard_period_close.py @@ -36,8 +36,8 @@ def _data_save(self, cr, uid, data, context): mode = 'done' if data['form']['sure']: for id in data['ids']: - cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id)) - cr.execute('update account_period set state=%s where id=%d', (mode, id)) + cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) + cr.execute('update account_period set state=%s where id=%s', (mode, id)) return {} class wiz_journal_close(wizard.interface): diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index 60ca40411ea..c8ebaccf49b 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -168,7 +168,7 @@ class crossovered_budget_lines(osv.osv): date_from = context['wizard_date_from'] if context.has_key('wizard_date_to'): date_to = context['wizard_date_to'] - cr.execute("select sum(amount) from account_analytic_line where account_id=%d and (date between to_date('%s','yyyy-mm-dd') and to_date('%s','yyyy-mm-dd')) and general_account_id in (%s)"%(line.analytic_account_id.id,date_from,date_to,acc_ids)) + cr.execute("select sum(amount) from account_analytic_line where account_id=%s and (date between to_date('%s','yyyy-mm-dd') and to_date('%s','yyyy-mm-dd')) and general_account_id in (%s)", (line.analytic_account_id.id,date_from,date_to,acc_ids)) result=cr.fetchone()[0] if result==None: result=0.00 diff --git a/addons/account_budget/report/budget_report.py b/addons/account_budget/report/budget_report.py index 8728ce449e2..da9d3776676 100644 --- a/addons/account_budget/report/budget_report.py +++ b/addons/account_budget/report/budget_report.py @@ -61,7 +61,7 @@ class budget_report(report_sxw.rml_parse): def lines(self, post_obj, date1, date2): res = [] for a in post_obj.account_ids: - self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%d AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2)) + self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%s AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2)) achievements = float(self.cr.fetchone()[0]) res.append({'name': a.name, 'code': a.code, 'achievements': achievements}) return res diff --git a/addons/account_followup/wizard/wizard_followup_print.py b/addons/account_followup/wizard/wizard_followup_print.py index cf3e2cdb409..d1ee95a00b4 100644 --- a/addons/account_followup/wizard/wizard_followup_print.py +++ b/addons/account_followup/wizard/wizard_followup_print.py @@ -129,8 +129,8 @@ class followup_all_print(wizard.interface): for id in to_update.keys(): cr.execute( "UPDATE account_move_line "\ - "SET followup_line_id=%d, followup_date=%s "\ - "WHERE id=%d", + "SET followup_line_id=%s, followup_date=%s "\ + "WHERE id=%s", (to_update[id], data['form']['date'], int(id),)) return {} @@ -230,7 +230,7 @@ class followup_all_print(wizard.interface): cr.execute( "SELECT * "\ "FROM account_followup_followup_line "\ - "WHERE followup_id=%d "\ + "WHERE followup_id=%s "\ "ORDER BY sequence", (fup_id,)) for result in cr.dictfetchall(): delay = datetime.timedelta(days=result['delay']) diff --git a/addons/account_invoice_layout/report/report_account_invoice_layout.py b/addons/account_invoice_layout/report/report_account_invoice_layout.py index f1f745d0579..1909d1de6a0 100644 --- a/addons/account_invoice_layout/report/report_account_invoice_layout.py +++ b/addons/account_invoice_layout/report/report_account_invoice_layout.py @@ -118,7 +118,7 @@ class account_invoice_1(report_sxw.rml_parse): res={} if entry.state=='article': - self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%d'%(entry.id)) + self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%s', (entry.id,)) tax_ids=self.cr.fetchall() if tax_ids==[]: @@ -126,7 +126,7 @@ class account_invoice_1(report_sxw.rml_parse): else: tax_names_dict={} for item in range(0,len(tax_ids)) : - self.cr.execute('select name from account_tax where id=%d'%(tax_ids[item][0])) + self.cr.execute('select name from account_tax where id=%s', (tax_ids[item][0],)) type=self.cr.fetchone() tax_names_dict[item] =type[0] tax_names = ','.join([tax_names_dict[x] for x in range(0,len(tax_names_dict))]) diff --git a/addons/account_invoice_layout/report/special_message_invoice.py b/addons/account_invoice_layout/report/special_message_invoice.py index f9129d412e8..e7aa4cdb727 100644 --- a/addons/account_invoice_layout/report/special_message_invoice.py +++ b/addons/account_invoice_layout/report/special_message_invoice.py @@ -124,7 +124,7 @@ class account_invoice_with_message(report_sxw.rml_parse): res={} if entry.state=='article': - self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%d'%(entry.id)) + self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%s', (entry.id,)) tax_ids=self.cr.fetchall() if tax_ids==[]: @@ -132,7 +132,7 @@ class account_invoice_with_message(report_sxw.rml_parse): else: tax_names_dict={} for item in range(0,len(tax_ids)) : - self.cr.execute('select name from account_tax where id=%d'%(tax_ids[item][0])) + self.cr.execute('select name from account_tax where id=%s', (tax_ids[item][0],)) type=self.cr.fetchone() tax_names_dict[item] =type[0] tax_names = ','.join([tax_names_dict[x] for x in range(0,len(tax_names_dict))]) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 10b3862f3c8..9c584d49c11 100755 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -299,7 +299,7 @@ class account_voucher(osv.osv): self.write(cr, uid, [inv.id], {'move_id': move_id}) obj=self.pool.get('account.move').browse(cr,uid,move_id) for line in obj.line_id : - cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id))) + cr.execute('insert into voucher_id (account_id,rel_account_move) values (%s, %s)',(int(ids[0]),int(line.id))) return True @@ -337,13 +337,13 @@ class account_voucher(osv.osv): else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_voucher SET number=%s ' \ - 'WHERE id=%d', (number, id)) + 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ - 'WHERE move_id=%d AND (ref is null OR ref = \'\')', + 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ - 'WHERE account_move_line.move_id = %d ' \ + 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True diff --git a/addons/auction/auction.py b/addons/auction/auction.py index 535830c09fd..bcf781f9e83 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -49,7 +49,7 @@ class auction_dates(osv.osv): tmp={} for id in ids: tmp[id]=0.0 - cr.execute("select sum(obj_price) from auction_lots where auction_id=%d", (id,)) + cr.execute("select sum(obj_price) from auction_lots where auction_id=%s", (id,)) sum = cr.fetchone() if sum: tmp[id]=sum[0] @@ -346,7 +346,7 @@ class auction_lots(osv.osv): res[lot.id] = 0.0 continue auct_id=lot.auction_id.id - cr.execute('select count(*) from auction_lots where auction_id=%d', (auct_id,)) + cr.execute('select count(*) from auction_lots where auction_id=%s', (auct_id,)) nb = cr.fetchone()[0] account_analytic_line_obj = self.pool.get('account.analytic.line') line_ids = account_analytic_line_obj.search(cr, uid, [('account_id', '=', lot.auction_id.account_analytic_id.id),('journal_id', '<>', lot.auction_id.journal_id.id),('journal_id', '<>', lot.auction_id.journal_seller_id.id)]) @@ -806,16 +806,16 @@ class auction_lots(osv.osv): def numerotate(self, cr, uid, ids): - cr.execute('select auction_id from auction_lots where id=%d', (ids[0],)) + cr.execute('select auction_id from auction_lots where id=%s', (ids[0],)) auc_id = cr.fetchone()[0] - cr.execute('select max(obj_num) from auction_lots where auction_id=%d', (auc_id,)) + cr.execute('select max(obj_num) from auction_lots where auction_id=%s', (auc_id,)) try: max = cr.fetchone()[0] except: max = 0 for id in ids: max+=1 - cr.execute('update auction_lots set obj_num=%d where id=%d', (max, id)) + cr.execute('update auction_lots set obj_num=%s where id=%s', (max, id)) return [] auction_lots() diff --git a/addons/auction/report/auction_total_rml.py b/addons/auction/report/auction_total_rml.py index 970c66d2d66..0cec8522b95 100644 --- a/addons/auction/report/auction_total_rml.py +++ b/addons/auction/report/auction_total_rml.py @@ -65,84 +65,84 @@ class auction_total_rml(report_sxw.rml_parse): def sum_taxes(self,auction_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d group by auction_id "%(auction_id)) + self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s group by auction_id ", (auction_id,)) res = self.cr.fetchone() return res[0] def sold_item(self, object_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and state in ('unsold') "%(object_id,)) + self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and state in ('unsold') ", (object_id,)) res = self.cr.fetchone() return str(res[0]) def sum_buyer(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and (ach_uid is not null or ach_login is not null) "%(auction_id)) + self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_seller(self, auction_id): - self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d AND bord_vnd_id is not null "%(auction_id)) + self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s AND bord_vnd_id is not null ", (auction_id,)) res = self.cr.fetchone() return res[0] def sum_adj(self, auction_id): - self.cr.execute("select sum(obj_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id)) + self.cr.execute("select sum(obj_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_take(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and ach_emp='True' "%(auction_id)) + self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and ach_emp='True' ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def chek_paid(self, auction_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and ((paid_ach='T') or (is_ok='T')) "%(auction_id)) + self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def check_paid_seller(self,auction_id): - self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and paid_vnd != 'T' "%(auction_id)) + self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and paid_vnd != 'T' ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0.0 def sum_credit(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id)) + self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_debit_buyer(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id)) + self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (auction_id,)) res = self.cr.fetchone() return str(res[0] or 0) def sum_debit(self,object_id): - self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%d "%(object_id,)) + self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%s", (object_id,)) res = self.cr.fetchone() return str(res[0] or 0) def sum_credit_seller(self, object_id): - self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(object_id)) + self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (object_id,)) res = self.cr.fetchone() return str(res[0] or 0) def sum_minadj(self, auction_id): - self.cr.execute('select sum(lot_est1) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%d '%(auction_id)) + self.cr.execute('select sum(lot_est1) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%s', (auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_maxadj(self, auction_id): - self.cr.execute('select sum(lot_est2) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%d '%(auction_id)) + self.cr.execute('select sum(lot_est2) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%s', (auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_buyer_paid(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and state = 'paid' "%(auction_id)) + self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and state = 'paid' ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_comm(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and obj_comm is not null "%(auction_id)) + self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and obj_comm is not null ", (auction_id,)) res = self.cr.fetchone() return str(res[0]) diff --git a/addons/auction/report/buyer_list.py b/addons/auction/report/buyer_list.py index 5c665eef995..0070dc0d58c 100644 --- a/addons/auction/report/buyer_list.py +++ b/addons/auction/report/buyer_list.py @@ -55,7 +55,7 @@ class buyer_list(report_sxw.rml_parse): auct_dat=[] for ad_id in auc_date_ids: auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name']) - self.cr.execute('select * from auction_buyer_taxes_rel abr,auction_dates ad where ad.id=abr.auction_id and ad.id=%d'%(ad_id[0],)) + self.cr.execute('select * from auction_buyer_taxes_rel abr,auction_dates ad where ad.id=abr.auction_id and ad.id=%s', (ad_id[0],)) res=self.cr.fetchall() total=0 for r in res: @@ -70,8 +70,8 @@ class buyer_list(report_sxw.rml_parse): auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])])) -# self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%d and ach_uid is not null group by ach_uid '%(auc_date_ids[0])) - self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%d and ach_login is not null group by ach_login order by ach_login'%(auc_date_ids[0])) +# self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_uid is not null group by ach_uid ', (auc_date_ids[0],)) + self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (auc_date_ids[0],)) res = self.cr.dictfetchall() for r in res: # if r['ach_uid']: diff --git a/addons/board/board.py b/addons/board/board.py index 912fb929f6d..1938de9840f 100644 --- a/addons/board/board.py +++ b/addons/board/board.py @@ -65,7 +65,7 @@ class board_board(osv.osv): view = self.create_view(cr, uid, ids[0], context) id = board.view_id.id - cr.execute("update ir_ui_view set arch='%s' where id=%d" % (view, id)) + cr.execute("update ir_ui_view set arch='%s' where id=%s" % (view, id)) cr.commit() return result diff --git a/addons/crm/crm_operators.py b/addons/crm/crm_operators.py index b0fa45d076c..e6354963f84 100644 --- a/addons/crm/crm_operators.py +++ b/addons/crm/crm_operators.py @@ -33,7 +33,7 @@ def som(cr, uid, partner_id, args): ''' select s.factor from res_partner_event e left join res_partner_som s - on (e.som=s.id) where partner_id=%d and date>=%s and date<%s''', + on (e.som=s.id) where partner_id=%s and date>=%s and date<%s''', (partner_id, time.strftime('%Y-%m-%d', time.gmtime(date_start)), time.strftime('%Y-%m-%d', time.gmtime(next_date)))) diff --git a/addons/crm/crm_segmentation.py b/addons/crm/crm_segmentation.py index 7b6ef9e03a3..8437dc0a0c2 100644 --- a/addons/crm/crm_segmentation.py +++ b/addons/crm/crm_segmentation.py @@ -59,7 +59,7 @@ class crm_segmentation(osv.osv): for categ in categs: if start: if categ['exclusif']: - cr.execute('delete from res_partner_category_rel where category_id=%d', (categ['categ_id'][0],)) + cr.execute('delete from res_partner_category_rel where category_id=%s', (categ['categ_id'][0],)) id = categ['id'] @@ -68,7 +68,7 @@ class crm_segmentation(osv.osv): if categ['sales_purchase_active']: to_remove_list=[] - cr.execute('select id from crm_segmentation_line where segmentation_id=%d', (id,)) + cr.execute('select id from crm_segmentation_line where segmentation_id=%s', (id,)) line_ids = [x[0] for x in cr.fetchall()] for pid in partners: @@ -78,7 +78,7 @@ class crm_segmentation(osv.osv): partners.remove(pid) for partner_id in partners: - cr.execute('insert into res_partner_category_rel (category_id,partner_id) values (%d,%d)', (categ['categ_id'][0],partner_id)) + cr.execute('insert into res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner_id)) cr.commit() self.write(cr, uid, [id], {'state':'not running', 'partner_id':0}) @@ -124,14 +124,14 @@ class crm_segmentation_line(osv.osv): cr.execute('SELECT SUM(l.price_unit * l.quantity) ' \ 'FROM account_invoice_line l, account_invoice i ' \ 'WHERE (l.invoice_id = i.id) ' \ - 'AND i.partner_id = %d '\ + 'AND i.partner_id = %s '\ 'AND i.type = \'out_invoice\'', (partner_id,)) value = cr.fetchone()[0] or 0.0 cr.execute('SELECT SUM(l.price_unit * l.quantity) ' \ 'FROM account_invoice_line l, account_invoice i ' \ 'WHERE (l.invoice_id = i.id) ' \ - 'AND i.partner_id = %d '\ + 'AND i.partner_id = %s '\ 'AND i.type = \'out_refund\'', (partner_id,)) value -= cr.fetchone()[0] or 0.0 @@ -139,14 +139,14 @@ class crm_segmentation_line(osv.osv): cr.execute('SELECT SUM(l.price_unit * l.quantity) ' \ 'FROM account_invoice_line l, account_invoice i ' \ 'WHERE (l.invoice_id = i.id) ' \ - 'AND i.partner_id = %d '\ + 'AND i.partner_id = %s '\ 'AND i.type = \'in_invoice\'', (partner_id,)) value = cr.fetchone()[0] or 0.0 cr.execute('SELECT SUM(l.price_unit * l.quantity) ' \ 'FROM account_invoice_line l, account_invoice i ' \ 'WHERE (l.invoice_id = i.id) ' \ - 'AND i.partner_id = %d '\ + 'AND i.partner_id = %s '\ 'AND i.type = \'in_refund\'', (partner_id,)) value -= cr.fetchone()[0] or 0.0 diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index a7e702bec05..65f11e8bfba 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -90,8 +90,8 @@ def _recompute_categ(self, cr, uid, pid, answers_ids): cr.execute(''' select r.category_id from res_partner_category_rel r left join crm_segmentation s on (r.category_id = s.categ_id) - where r.partner_id = %d and (s.exclusif = false or s.exclusif is null); - '''% pid) + where r.partner_id = %s and (s.exclusif = false or s.exclusif is null) + ''', (pid,)) for x in cr.fetchall(): ok.append(x[0]) @@ -173,10 +173,8 @@ class partner(osv.osv): if x.startswith("quest_form") and data['form'][x] != 0 : temp.append(data['form'][x]) - query = """ - select answer from partner_question_rel - where partner =%d"""% data['id'] - cr.execute(query) + query = "select answer from partner_question_rel where partner=%s" + cr.execute(query, data['id']) for x in cr.fetchall(): temp.append(x[0]) @@ -212,7 +210,7 @@ class crm_segmentation(osv.osv): for categ in categs: if start: if categ['exclusif']: - cr.execute('delete from res_partner_category_rel where category_id=%d', (categ['categ_id'][0],)) + cr.execute('delete from res_partner_category_rel where category_id=%s', (categ['categ_id'][0],)) id = categ['id'] @@ -221,7 +219,7 @@ class crm_segmentation(osv.osv): if categ['sales_purchase_active']: to_remove_list=[] - cr.execute('select id from crm_segmentation_line where segmentation_id=%d', (id,)) + cr.execute('select id from crm_segmentation_line where segmentation_id=%s', (id,)) line_ids = [x[0] for x in cr.fetchall()] for pid in partners: @@ -234,7 +232,7 @@ class crm_segmentation(osv.osv): to_remove_list=[] for pid in partners: - cr.execute('select distinct(answer) from partner_question_rel where partner=%d' % pid) + cr.execute('select distinct(answer) from partner_question_rel where partner=%s',(pid,)) answers_ids = [x[0] for x in cr.fetchall()] if (not test_prof(cr, uid, id, pid, answers_ids)): @@ -243,7 +241,7 @@ class crm_segmentation(osv.osv): partners.remove(pid) for partner_id in partners: - cr.execute('insert into res_partner_category_rel (category_id,partner_id) values (%d,%d)', (categ['categ_id'][0],partner_id)) + cr.execute('insert into res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner_id)) cr.commit() self.write(cr, uid, [id], {'state':'not running', 'partner_id':0}) diff --git a/addons/document/document.py b/addons/document/document.py index e7929f2ba90..afb466c983a 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -35,7 +35,7 @@ import StringIO import random import string - +from psycopg2 import Binary from tools import config def random_name(): @@ -522,9 +522,9 @@ class document_file(osv.osv): v = base64.decodestring(value) fp.write(v) filesize = os.stat(fname).st_size - cr.execute('update ir_attachment set store_fname=%s,store_method=%s,file_size=%d where id=%d', (os.path.join(flag,filename),'fs',len(v),id)) + cr.execute('update ir_attachment set store_fname=%s,store_method=%s,file_size=%s where id=%s', (os.path.join(flag,filename),'fs',len(v),id)) else: - cr.execute('update ir_attachment set datas=%s,store_method=%s where id=%d', (psycopg.Binary(value),'db',id)) + cr.execute('update ir_attachment set datas=%s,store_method=%s where id=%s', (Binary(value),'db',id)) return True _columns = { diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py index 4c0183122b8..9cc0f2d5868 100644 --- a/addons/document/ftpserver/abstracted_fs.py +++ b/addons/document/ftpserver/abstracted_fs.py @@ -494,7 +494,7 @@ class abstracted_fs: elif src.object.res_id: # I had to do that because writing False to an integer writes 0 instead of NULL # change if one day we decide to improve osv/fields.py - dst_basedir.cr.execute('update ir_attachment set res_id=NULL where id=%d', (src.object.id,)) + dst_basedir.cr.execute('update ir_attachment set res_id=NULL where id=%s', (src.object.id,)) pool.get('ir.attachment').write(src.cr, src.uid, [src.object.id], val) src.cr.commit() diff --git a/addons/event/wizard/event_registration.py b/addons/event/wizard/event_registration.py index 2ae20b7ce90..cb76e6c929f 100644 --- a/addons/event/wizard/event_registration.py +++ b/addons/event/wizard/event_registration.py @@ -24,7 +24,7 @@ import pooler def _event_registration(self, cr, uid, data, context): event_id = data['id'] - cr.execute(''' SELECT section_id FROM event_event WHERE id = %d '''% (event_id, )) + cr.execute('SELECT section_id FROM event_event WHERE id = %s', (event_id, )) res = cr.fetchone() value = { 'domain': [('section_id', '=', res[0])], diff --git a/addons/event_project/wizard/event_task.py b/addons/event_project/wizard/event_task.py index 83426d008e7..6fd77fb21e0 100644 --- a/addons/event_project/wizard/event_task.py +++ b/addons/event_project/wizard/event_task.py @@ -24,7 +24,7 @@ import pooler def _event_tasks(self, cr, uid, data, context): event_id = data['id'] - cr.execute('''SELECT project_id FROM event_event WHERE id = %d '''% (event_id, )) + cr.execute('SELECT project_id FROM event_event WHERE id = %s', (event_id, )) res = cr.fetchone() if not res[0]: raise wizard.except_wizard('Error !', 'No project defined for this event.\nYou can create one with the retro-planning button !') diff --git a/addons/hr/hr.py b/addons/hr/hr.py index bd403ce2c42..8f05ffcd1f1 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -45,7 +45,7 @@ class hr_timesheet_group(osv.osv): cycle = 0 result = [] while todo>0: - cr.execute("select hour_from,hour_to from hr_timesheet where dayofweek='%s' and tgroup_id=%d order by hour_from", (dt_from.day_of_week,id)) + cr.execute("select hour_from,hour_to from hr_timesheet where dayofweek='%s' and tgroup_id=%s order by hour_from", (dt_from.day_of_week,id)) for (hour_from,hour_to) in cr.fetchall(): h1,m1 = map(int,hour_from.split(':')) h2,m2 = map(int,hour_to.split(':')) diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index dfa1e3a7635..c0ecd34a0c0 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -130,7 +130,7 @@ class hr_employee(osv.osv): return id def _action_check(self, cr, uid, emp_id, dt=False,context={}): - cr.execute('select max(name) from hr_attendance where employee_id=%d', (emp_id,)) + cr.execute('select max(name) from hr_attendance where employee_id=%s', (emp_id,)) res = cr.fetchone() return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S')))) diff --git a/addons/hr_attendance/report/attendance_errors.py b/addons/hr_attendance/report/attendance_errors.py index 96d052a67aa..90d776139fe 100644 --- a/addons/hr_attendance/report/attendance_errors.py +++ b/addons/hr_attendance/report/attendance_errors.py @@ -44,7 +44,7 @@ class attendance_print(report_sxw.rml_parse): return dt.strftime(format) def _lst(self, employee_id, dt_from, dt_to, max, *args): - self.cr.execute('select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%d and name<=%s and name>=%s and action in (%s,%s) order by name', (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) + self.cr.execute('select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and name<=%s and name>=%s and action in (%s,%s) order by name', (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) res = self.cr.dictfetchall() for r in res: if r['action']=='sign_out': @@ -58,7 +58,7 @@ class attendance_print(report_sxw.rml_parse): return res def _lst_total(self, employee_id, dt_from, dt_to, max, *args): - self.cr.execute('select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%d and name<=%s and name>=%s and action in (%s,%s)', (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) + self.cr.execute('select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and name<=%s and name>=%s and action in (%s,%s)', (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) res = self.cr.dictfetchall() if not res: return ('/','/') diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index c4b7158b05c..3cedf2b4faf 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -205,7 +205,7 @@ class report_custom(report_rml): dept = pooler.get_pool(cr.dbname).get('hr.department').browse(cr, uid, id, context.copy()) depts.append(dept) - cr.execute('select user_id from hr_department_user_rel where department_id=%d'%(dept.id)) + cr.execute('select user_id from hr_department_user_rel where department_id=%s', (dept.id,)) result=cr.fetchall() if result==[]: diff --git a/addons/hr_timesheet/report/user_timesheet.py b/addons/hr_timesheet/report/user_timesheet.py index 07742b451b1..dbc553050f9 100644 --- a/addons/hr_timesheet/report/user_timesheet.py +++ b/addons/hr_timesheet/report/user_timesheet.py @@ -61,7 +61,7 @@ class report_custom(report_rml): "account_analytic_account as account, product_uom as unit "\ "where hr.line_id=line.id and line.account_id=account.id "\ "and product_uom_id = unit.id "\ - "and line.user_id=%d and line.date >= %s and line.date < %s " + "and line.user_id=%s and line.date >= %s and line.date < %s " "order by line.date", (data['form']['user_id'], som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d'))) @@ -88,7 +88,7 @@ class report_custom(report_rml): account_xml.append('') # Computing the employee - cr.execute("select name from res_users where id=%d", (data['form']['user_id'],)) + cr.execute("select name from res_users where id=%s", (data['form']['user_id'],)) emp = cr.fetchone()[0] # Computing the xml diff --git a/addons/hr_timesheet/report/users_timesheet.py b/addons/hr_timesheet/report/users_timesheet.py index 8ba187da4a2..98ceaf5eb65 100644 --- a/addons/hr_timesheet/report/users_timesheet.py +++ b/addons/hr_timesheet/report/users_timesheet.py @@ -40,7 +40,7 @@ def emp_create_xml(cr, id, som, eom): "product_uom as unit "\ "where hr.line_id=line.id "\ "and product_uom_id = unit.id "\ - "and line.user_id=%d and line.date >= %s and line.date < %s " + "and line.user_id=%s and line.date >= %s and line.date < %s " "order by line.date", (id, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d'))) @@ -58,7 +58,7 @@ def emp_create_xml(cr, id, som, eom): time_xml = ([xml % (day, amount) for day, amount in month.iteritems()]) # Computing the employee - cr.execute("select name from res_users where id=%d", (id,)) + cr.execute("select name from res_users where id=%s", (id,)) emp = cr.fetchone()[0] # Computing the xml diff --git a/addons/hr_timesheet/wizard/sign_in_out.py b/addons/hr_timesheet/wizard/sign_in_out.py index 1142355a367..d2a6f771310 100644 --- a/addons/hr_timesheet/wizard/sign_in_out.py +++ b/addons/hr_timesheet/wizard/sign_in_out.py @@ -80,7 +80,7 @@ def _get_empid(self, cr, uid, data, context): def _get_empid2(self, cr, uid, data, context): res = _get_empid(self,cr, uid, data, context) - cr.execute('select name,action from hr_attendance where employee_id=%d order by name desc limit 1', (res['emp_id'],)) + cr.execute('select name,action from hr_attendance where employee_id=%s order by name desc limit 1', (res['emp_id'],)) res['server_date'] = time.strftime('%Y-%m-%d %H:%M:%S') res['date_start'] = cr.fetchone()[0] res['info'] = '' @@ -133,7 +133,7 @@ def _sign_out_result(self, cr, uid, data, context): def _state_check(self, cr, uid, data, context): emp_id = _get_empid(self, cr, uid, data, context)['emp_id'] # get the latest action (sign_in or out) for this employee - cr.execute('select action from hr_attendance where employee_id=%d and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,)) + cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,)) res = (cr.fetchone() or ('sign_out',))[0] #TODO: invert sign_in et sign_out return res diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.py b/addons/hr_timesheet_invoice/report/account_analytic_profit.py index 0cd9a8de359..b8e1884ca5a 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.py @@ -90,7 +90,7 @@ class account_analytic_profit(report_sxw.rml_parse): xxx = round(price * line.unit_amount * (1-(discount or 0.0)), 2) res[id]['amount_th']+=xxx if line.invoice_id: - self.cr.execute('select id from account_analytic_line where invoice_id=%d', (line.invoice_id.id,)) + self.cr.execute('select id from account_analytic_line where invoice_id=%s', (line.invoice_id.id,)) tot = 0 for lid in self.cr.fetchall(): lid2 = line_obj.browse(self.cr, self.uid, lid[0]) diff --git a/addons/hr_timesheet_invoice/report/cost_ledger.py b/addons/hr_timesheet_invoice/report/cost_ledger.py index fd328c63e49..3f0703492bd 100644 --- a/addons/hr_timesheet_invoice/report/cost_ledger.py +++ b/addons/hr_timesheet_invoice/report/cost_ledger.py @@ -50,7 +50,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _lines_g(self, account_id, date1, date2): self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id, sum(aal.unit_amount) AS quantity \ FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2)) res = self.cr.dictfetchall() @@ -69,7 +69,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _lines_a(self, general_account_id, account_id, date1, date2): self.cr.execute("SELECT aal.id AS id, aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj, aal.unit_amount AS quantity \ FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2)) res = self.cr.dictfetchall() @@ -105,11 +105,11 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _account_sum_debit(self, account_id, date1, date2): - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_credit(self, account_id, date1, date2): - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_balance(self, account_id, date1, date2): @@ -118,7 +118,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return (debit-credit) def _account_sum_qty(self, account_id, date1, date2): - self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s", (account_id, date1, date2)) + self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s", (account_id, date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_revenue(self, account_id): diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py index 62353018520..8b858f43ec3 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py @@ -79,7 +79,7 @@ class final_invoice_create(wizard.interface): context2['lang'] = partner.lang cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ "FROM account_analytic_line as line " \ - "WHERE account_id = %d " \ + "WHERE account_id = %s " \ "AND to_invoice IS NOT NULL " \ "GROUP BY product_id, to_invoice", (account.id,)) @@ -94,14 +94,14 @@ class final_invoice_create(wizard.interface): LEFT JOIN account_move_line as move_line on (line.move_id=move_line.id) LEFT JOIN account_analytic_journal as journal on (line.journal_id=journal.id) WHERE - line.account_id = %d AND + line.account_id = %s AND line.move_id IS NOT NULL AND journal.type = 'sale' GROUP BY line.product_id, line.general_account_id, line.product_uom_id, - move_line.ref""" % (account.id)) + move_line.ref""", (account.id,)) for product_id, amount, account_id, product_uom_id, ref in cr.fetchall(): product = pool.get('product.product').browse(cr, uid, product_id, context2) @@ -147,7 +147,7 @@ class final_invoice_create(wizard.interface): pool.get('account.invoice.line').create(cr, uid, curr_line) if account.amount_max < amount_total: pool.get('account.invoice').write(cr, uid, [last_invoice], {'type': 'out_refund',}) - cr.execute('update account_analytic_line set invoice_id=%d where invoice_id is null and account_id=%d', (last_invoice, account.id)) + cr.execute('update account_analytic_line set invoice_id=%s where invoice_id is null and account_id=%s', (last_invoice, account.id)) return { 'domain': "[('id','in', ["+','.join(map(str,invoices))+"])]", diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index b85cba38bf4..f5fec52775f 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -87,7 +87,7 @@ class invoice_create(wizard.interface): context2['lang'] = partner.lang cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ "FROM account_analytic_line as line " \ - "WHERE account_id = %d " \ + "WHERE account_id = %s " \ "AND id IN (" + ','.join([str(x) for x in data['ids']]) + ") " \ "AND to_invoice IS NOT NULL " \ "GROUP BY product_id,to_invoice", (account.id,)) @@ -128,7 +128,7 @@ class invoice_create(wizard.interface): # # Compute for lines # - cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %d and id IN (%s) AND product_id=%d and to_invoice=%d" % (account.id, ','.join(map(str,data['ids'])), product_id, factor_id)) + cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id IN (%s) AND product_id=%s and to_invoice=%s", (account.id, ','.join(map(str,data['ids'])), product_id, factor_id)) line_ids = cr.dictfetchall() note = [] for line in line_ids: @@ -149,7 +149,8 @@ class invoice_create(wizard.interface): curr_line['note'] = "\n".join(map(str,note)) pool.get('account.invoice.line').create(cr, uid, curr_line) - cr.execute("update account_analytic_line set invoice_id=%d WHERE account_id = %d and id IN (%s)" % (last_invoice,account.id, ','.join(map(str,data['ids'])))) + strids = ','.join(map(str, data['ids'])) + cr.execute("update account_analytic_line set invoice_id=%%s WHERE account_id = %%s and id IN (%s)" % strids, (last_invoice,account.id,)) return { 'domain': "[('id','in', ["+','.join(map(str,invoices))+"])]", diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 114a4a72997..ebcf1996764 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -261,8 +261,8 @@ class hr_timesheet_sheet(osv.osv): cr.execute('SELECT id \ FROM hr_timesheet_sheet_sheet \ WHERE (date_from < %s and %s < date_to) \ - AND user_id=%d \ - AND id <> %d', (sheet.date_to, sheet.date_from, + AND user_id=%s \ + AND id <> %s', (sheet.date_to, sheet.date_from, sheet.user_id.id, sheet.id)) if cr.fetchall(): return False diff --git a/addons/l10n_be/wizard/partner_vat_listing.py b/addons/l10n_be/wizard/partner_vat_listing.py index a79c3b053ce..9e76d79efb5 100644 --- a/addons/l10n_be/wizard/partner_vat_listing.py +++ b/addons/l10n_be/wizard/partner_vat_listing.py @@ -114,7 +114,7 @@ class wizard_vat(wizard.interface): for p_id in p_id_list: record=[] # this holds record per partner obj_partner=pooler.get_pool(cr.dbname).get('res.partner').browse(cr,uid,p_id) - cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in ('"'produit'"','"'tax'"') and l.partner_id=%d and l.date between %s group by a.type'%(p_id,period)) + cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in ('"'produit'"','"'tax'"') and l.partner_id=%%s and l.date between %s group by a.type' % (period,), (p_id,)) line_info=cr.fetchall() if not line_info: continue diff --git a/addons/membership/membership.py b/addons/membership/membership.py index a7049c0f204..9752fcd7737 100644 --- a/addons/membership/membership.py +++ b/addons/membership/membership.py @@ -181,10 +181,10 @@ class membership_line(osv.osv): l.id = ( SELECT ml.account_invoice_line FROM membership_membership_line ml WHERE - ml.id = %d + ml.id = %s ) ) - ''' % line.id) + ''', (line.id,)) fetched = cr.fetchone() if not fetched : res[line.id] = 'canceled' @@ -283,7 +283,7 @@ class Partner(osv.osv): res[id] = 'free' if partner_data.associate_member: assciate_partner = self.browse(cr,uid,partner_data.associate_member.id) - cr.execute('select membership_state from res_partner where id=%d', (partner_data.id,)) + cr.execute('select membership_state from res_partner where id=%s', (partner_data.id,)) data_partner_state = cr.fetchall() for i in assciate_partner.member_lines: if i.date_from <= today and i.date_to >= today and i.account_invoice_line.invoice_id.state == 'paid' and s!=0 and data_partner_state[0][0] !='free': @@ -358,7 +358,7 @@ class Partner(osv.osv): res = {} member_line_obj = self.pool.get('membership.membership_line') for partner in self.browse(cr, uid, ids): - cr.execute('select membership_state from res_partner where id=%d', (partner.id,)) + cr.execute('select membership_state from res_partner where id=%s', (partner.id,)) data_state = cr.fetchall() #if partner.membership_state == 'associated': if data_state[0][0] == 'associated': diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 36e7492d8b9..288d17f4244 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -238,7 +238,7 @@ class mrp_bom(osv.osv): def _bom_find(self, cr, uid, product_id, product_uom, properties = []): bom_result = False # Why searching on BoM without parent ? - cr.execute('select id from mrp_bom where product_id=%d and bom_id is null order by sequence', (product_id,)) + cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,)) ids = map(lambda x: x[0], cr.fetchall()) max_prop = 0 result = False @@ -467,8 +467,8 @@ class mrp_production(osv.osv): def action_compute(self, cr, uid, ids, properties=[]): results = [] for production in self.browse(cr, uid, ids): - cr.execute('delete from mrp_production_product_line where production_id=%d', (production.id,)) - cr.execute('delete from mrp_production_workcenter_line where production_id=%d', (production.id,)) + cr.execute('delete from mrp_production_product_line where production_id=%s', (production.id,)) + cr.execute('delete from mrp_production_workcenter_line where production_id=%s', (production.id,)) bom_point = production.bom_id bom_id = production.bom_id.id if not bom_point: @@ -522,7 +522,7 @@ class mrp_production(osv.osv): for move in production.move_created_ids: #XXX must use the orm cr.execute('INSERT INTO stock_move_history_ids \ - (parent_id, child_id) VALUES (%d,%d)', + (parent_id, child_id) VALUES (%s,%s)', (res.id, move.id)) move_ids.append(res.id) vals= {'state':'confirmed'} @@ -874,7 +874,7 @@ class mrp_procurement(osv.osv): properties = [x.id for x in procurement.property_ids] bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties) if not bom_id: - cr.execute('update mrp_procurement set message=%s where id=%d', (_('No BoM defined for this product !'), procurement.id)) + cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id)) return False return True @@ -912,7 +912,7 @@ class mrp_procurement(osv.osv): if procurement.product_id.product_tmpl_id.supply_method<>'buy': return False if not procurement.product_id.seller_ids: - cr.execute('update mrp_procurement set message=%s where id=%d', (_('No supplier defined for this product !'), procurement.id)) + cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id)) return False partner = procurement.product_id.seller_ids[0].name if user.company_id and user.company_id.partner_id: @@ -920,7 +920,7 @@ class mrp_procurement(osv.osv): return False address_id = self.pool.get('res.partner').address_get(cr, uid, [partner.id], ['delivery'])['delivery'] if not address_id: - cr.execute('update mrp_procurement set message=%s where id=%d', (_('No address defined for the supplier'), procurement.id)) + cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id)) return False return True @@ -968,9 +968,9 @@ class mrp_procurement(osv.osv): id = procurement.move_id.id if not (procurement.move_id.state in ('done','assigned','cancel')): ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id]) - cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%d', (procurement.product_id.id,)) + cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,)) if not cr.fetchone()[0]: - cr.execute('update mrp_procurement set message=%s where id=%d', (_('from stock and no minimum orderpoint rule defined'), procurement.id)) + cr.execute('update mrp_procurement set message=%s where id=%s', (_('from stock and no minimum orderpoint rule defined'), procurement.id)) return ok def action_produce_assign_service(self, cr, uid, ids, context={}): diff --git a/addons/mrp/report/workcenter_load.py b/addons/mrp/report/workcenter_load.py index 820654b821e..41ff23786a8 100644 --- a/addons/mrp/report/workcenter_load.py +++ b/addons/mrp/report/workcenter_load.py @@ -148,7 +148,7 @@ class report_custom(report_int): FROM mrp_production_workcenter_line, mrp_production, mrp_workcenter \ WHERE (mrp_production_workcenter_line.production_id=mrp_production.id) \ AND (mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id) \ - AND (mrp_workcenter.id=%d) \ + AND (mrp_workcenter.id=%s) \ AND (mrp_production.date_planned BETWEEN %s AND %s) \ GROUP BY mrp_production_workcenter_line.workcenter_id, mrp_workcenter.name, mrp_workcenter.id \ ORDER BY mrp_workcenter.id", (workcenter['id'], dates[date]['start'] + ' 00:00:00', dates[date]['stop'] + ' 23:59:59')) diff --git a/addons/mrp/schedulers.py b/addons/mrp/schedulers.py index a15cc9c42c7..6e97ba30b1e 100644 --- a/addons/mrp/schedulers.py +++ b/addons/mrp/schedulers.py @@ -56,7 +56,7 @@ class mrp_procurement(osv.osv): report_except = 0 report_later = 0 while True: - cr.execute('select id from mrp_procurement where state=%s and procure_method=%s order by date_planned limit 500 offset %d', ('confirmed','make_to_order',offset)) + cr.execute('select id from mrp_procurement where state=%s and procure_method=%s order by date_planned limit 500 offset %s', ('confirmed','make_to_order',offset)) ids = map(lambda x:x[0], cr.fetchall()) for proc in procurement_obj.browse(cr, uid, ids): if maxdate.strftime('%Y-%m-%d')>=proc.date_planned: diff --git a/addons/point_of_sale/report/pos_receipt.py b/addons/point_of_sale/report/pos_receipt.py index 85896098987..0cb68398515 100644 --- a/addons/point_of_sale/report/pos_receipt.py +++ b/addons/point_of_sale/report/pos_receipt.py @@ -41,14 +41,14 @@ class order(report_sxw.rml_parse): }) def netamount(self, order_line_id): - sql = 'select (qty*price_unit) as net_price from pos_order_line where id = %d ' - self.cr.execute(sql%(order_line_id)) + sql = 'select (qty*price_unit) as net_price from pos_order_line where id = %s' + self.cr.execute(sql, (order_line_id,)) res = self.cr.fetchone() return res[0] def discount(self, order_id): - sql = 'select discount, price_unit, qty from pos_order_line where order_id = %d ' - self.cr.execute(sql%(order_id)) + sql = 'select discount, price_unit, qty from pos_order_line where order_id = %s ' + self.cr.execute(sql, (order_id,)) res = self.cr.fetchall() dsum = 0 for line in res: diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 8df19271288..a8509f1c06f 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -130,7 +130,7 @@ class product_pricelist(osv.osv): for id in ids: cr.execute('SELECT * ' \ 'FROM product_pricelist_version ' \ - 'WHERE pricelist_id = %d AND active=True ' \ + 'WHERE pricelist_id = %s AND active=True ' \ 'AND (date_start IS NULL OR date_start <= %s) ' \ 'AND (date_end IS NULL OR date_end >= %s) ' \ 'ORDER BY id LIMIT 1', (id, date, date)) @@ -145,14 +145,14 @@ class product_pricelist(osv.osv): 'FROM product_template ' \ 'WHERE id = (SELECT product_tmpl_id ' \ 'FROM product_product ' \ - 'WHERE id = %d)', (prod_id,)) + 'WHERE id = %s)', (prod_id,)) tmpl_id, categ = cr.fetchone() categ_ids = [] while categ: categ_ids.append(str(categ)) cr.execute('SELECT parent_id ' \ 'FROM product_category ' \ - 'WHERE id = %d', (categ,)) + 'WHERE id = %s', (categ,)) categ = cr.fetchone()[0] if str(categ) in categ_ids: raise osv.except_osv(_('Warning !'), @@ -168,11 +168,11 @@ class product_pricelist(osv.osv): 'SELECT i.*, pl.currency_id ' 'FROM product_pricelist_item AS i, ' 'product_pricelist_version AS v, product_pricelist AS pl ' - 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %d) ' - 'AND (product_id IS NULL OR product_id = %d) ' + 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) ' + 'AND (product_id IS NULL OR product_id = %s) ' 'AND (' + categ_where + ' OR (categ_id IS NULL)) ' - 'AND price_version_id = %d ' - 'AND (min_quantity IS NULL OR min_quantity <= %f) ' + 'AND price_version_id = %s ' + 'AND (min_quantity IS NULL OR min_quantity <= %s) ' 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id ' 'ORDER BY sequence LIMIT 1', (tmpl_id, prod_id, plversion['id'], qty)) @@ -201,7 +201,7 @@ class product_pricelist(osv.osv): 'FROM pricelist_partnerinfo ' \ 'WHERE suppinfo_id IN (' + \ ','.join(map(str, sinfo)) + ') ' \ - 'AND min_quantity <= %f ' \ + 'AND min_quantity <= %s ' \ 'ORDER BY min_quantity DESC LIMIT 1', (qty,)) res2 = cr.dictfetchone() if res2: @@ -275,9 +275,9 @@ class product_pricelist_version(osv.osv): 'OR (%s = \'0000-01-01\' AND %s = \'0000-01-01\') ' \ 'OR (%s = \'0000-01-01\' AND date_start <= %s) ' \ 'OR (%s = \'0000-01-01\' AND %s <= date_end)) ' \ - 'AND pricelist_id = %d ' \ + 'AND pricelist_id = %s ' \ 'AND active ' \ - 'AND id <> %d', (pricelist_version.date_end or '0000-01-01', + 'AND id <> %s', (pricelist_version.date_end or '0000-01-01', pricelist_version.date_start or '0000-01-01', pricelist_version.date_end or '0000-01-01', pricelist_version.date_start or '0000-01-01', diff --git a/addons/project/project.py b/addons/project/project.py index 4d9261f2ea0..41e6750ecc3 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -153,11 +153,11 @@ class project(osv.osv): for proj in self.browse(cr, uid, ids): parent_id=context.get('parent_id',False) new_id=self.pool.get('project.project').copy(cr, uid, proj.id,default={'name':proj.name+_(' (copy)'),'state':'open','parent_id':parent_id}) - cr.execute('select id from project_task where project_id=%d', (proj.id,)) + cr.execute('select id from project_task where project_id=%s', (proj.id,)) res = cr.fetchall() for (tasks_id,) in res: self.pool.get('project.task').copy(cr, uid, tasks_id,default={'project_id':new_id,'active':True}, context=context) - cr.execute('select id from project_project where parent_id=%d', (proj.id,)) + cr.execute('select id from project_project where parent_id=%s', (proj.id,)) res = cr.fetchall() project_ids = [x[0] for x in res] for child in project_ids: @@ -172,11 +172,11 @@ class project(osv.osv): def setActive(self, cr, uid, ids, value=True, context={}): for proj in self.browse(cr, uid, ids, context): self.write(cr, uid, [proj.id], {'state': value and 'open' or 'template'}, context) - cr.execute('select id from project_task where project_id=%d', (proj.id,)) + cr.execute('select id from project_task where project_id=%s', (proj.id,)) tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: self.pool.get('project.task').write(cr, uid, tasks_id, {'active': value}, context) - cr.execute('select id from project_project where parent_id=%d', (proj.id,)) + cr.execute('select id from project_project where parent_id=%s', (proj.id,)) project_ids = [x[0] for x in cr.fetchall()] for child in project_ids: self.setActive(cr, uid, [child], value, context) @@ -410,17 +410,17 @@ class project_work(osv.osv): _order = "date desc" def create(self, cr, uid, vals, *args, **kwargs): if 'task_id' in vals: - cr.execute('update project_task set remaining_hours=remaining_hours+%.2f where id=%d', (-vals.get('hours',0.0), vals['task_id'])) + cr.execute('update project_task set remaining_hours=remaining_hours+%.2f where id=%s', (-vals.get('hours',0.0), vals['task_id'])) return super(project_work,self).create(cr, uid, vals, *args, **kwargs) def write(self, cr, uid, ids,vals,context={}): for work in self.browse(cr, uid, ids, context): - cr.execute('update project_task set remaining_hours=remaining_hours+%.2f+(%.2f) where id=%d', (-vals.get('hours',0.0), work.hours, work.task_id.id)) + cr.execute('update project_task set remaining_hours=remaining_hours+%.2f+(%.2f) where id=%s', (-vals.get('hours',0.0), work.hours, work.task_id.id)) return super(project_work,self).write(cr, uid, ids, vals, context) def unlink(self, cr, uid, ids, *args, **kwargs): for work in self.browse(cr, uid, ids): - cr.execute('update project_task set remaining_hours=remaining_hours+%.2f where id=%d', (work.hours, work.task_id.id)) + cr.execute('update project_task set remaining_hours=remaining_hours+%.2f where id=%s', (work.hours, work.task_id.id)) return super(project_work,self).unlink(cr, uid, ids,*args, **kwargs) project_work() diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d13901574e5..c0c4e5c8dad 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -86,7 +86,7 @@ class purchase_order(osv.osv): cr.execute("""update purchase_order_line set date_planned=%s where - order_id=%d and + order_id=%s and (date_planned=%s or date_planned<%s)""", (value,po.id,po.minimum_planned_date,value)) return True diff --git a/addons/purchase/report/order.py b/addons/purchase/report/order.py index 2447f618955..c86e1813730 100644 --- a/addons/purchase/report/order.py +++ b/addons/purchase/report/order.py @@ -35,7 +35,7 @@ class order(report_sxw.rml_parse): 'get_product_code': self._get_product_code, }) def _get_line_tax(self, line_obj): - self.cr.execute("SELECT tax_id FROM purchase_order_taxe WHERE order_line_id=%d" % (line_obj.id)) + self.cr.execute("SELECT tax_id FROM purchase_order_taxe WHERE order_line_id=%s", (line_obj.id)) res = self.cr.fetchall() or None if not res: return "" @@ -48,7 +48,7 @@ class order(report_sxw.rml_parse): def _get_tax(self, order_obj): self.cr.execute("SELECT DISTINCT tax_id FROM purchase_order_taxe, purchase_order_line, purchase_order \ - WHERE (purchase_order_line.order_id=purchase_order.id) AND (purchase_order.id=%d)" % (order_obj.id)) + WHERE (purchase_order_line.order_id=purchase_order.id) AND (purchase_order.id=%s)", (order_obj.id)) res = self.cr.fetchall() or None if not res: return [] @@ -60,7 +60,7 @@ class order(report_sxw.rml_parse): res = [] for tax in tax_obj.browse(self.cr, self.uid, tax_ids): self.cr.execute("SELECT DISTINCT order_line_id FROM purchase_order_line, purchase_order_taxe \ - WHERE (purchase_order_taxe.tax_id=%d) AND (purchase_order_line.order_id=%d)" % (tax.id, order_obj.id)) + WHERE (purchase_order_taxe.tax_id=%s) AND (purchase_order_line.order_id=%s)", (tax.id, order_obj.id)) lines = self.cr.fetchall() or None if lines: if isinstance(lines, list): diff --git a/addons/report_analytic_planning/report_analytic_planning.py b/addons/report_analytic_planning/report_analytic_planning.py index 3a5a9c1815f..7e7d687aa25 100644 --- a/addons/report_analytic_planning/report_analytic_planning.py +++ b/addons/report_analytic_planning/report_analytic_planning.py @@ -73,7 +73,7 @@ class report_account_analytic_planning_stat_account(osv.osv): def _sum_amount_real(self, cr, uid, ids, name, args, context): result = {} for line in self.browse(cr, uid, ids, context): - cr.execute('select sum(unit_amount) from account_analytic_line where account_id=%d and date>=%s and date<=%s', (line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) + cr.execute('select sum(unit_amount) from account_analytic_line where account_id=%s and date>=%s and date<=%s', (line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) result[line.id] = cr.fetchone()[0] return result _columns = { @@ -110,9 +110,9 @@ class report_account_analytic_planning_stat(osv.osv): result = {} for line in self.browse(cr, uid, ids, context): if line.user_id: - cr.execute('select sum(unit_amount) from account_analytic_line where user_id=%d and account_id=%d and date>=%s and date<=%s', (line.user_id.id,line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) + cr.execute('select sum(unit_amount) from account_analytic_line where user_id=%s and account_id=%s and date>=%s and date<=%s', (line.user_id.id,line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) else: - cr.execute('select sum(unit_amount) from account_analytic_line where account_id=%d and date>=%s and date<=%s', (line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) + cr.execute('select sum(unit_amount) from account_analytic_line where account_id=%s and date>=%s and date<=%s', (line.account_id.id,line.planning_id.date_from,line.planning_id.date_to)) result[line.id] = cr.fetchone()[0] return result def _sum_amount_tasks(self, cr, uid, ids, name, args, context): @@ -127,7 +127,7 @@ class report_account_analytic_planning_stat(osv.osv): project_task where '''+where+''' - project_id in (select id from project_project where category_id=%d) and + project_id in (select id from project_project where category_id=%s) and date_close>=%s and date_close<=%s''', ( line.account_id.id, @@ -179,7 +179,7 @@ class report_account_analytic_planning_stat_user(osv.osv): for line in self.browse(cr, uid, ids, context): result[line.id] = 0.0 if line.user_id: - cr.execute('select sum(unit_amount) from account_analytic_line where user_id=%d and date>=%s and date<=%s', (line.user_id.id,line.planning_id.date_from,line.planning_id.date_to)) + cr.execute('select sum(unit_amount) from account_analytic_line where user_id=%s and date>=%s and date<=%s', (line.user_id.id,line.planning_id.date_from,line.planning_id.date_to)) result[line.id] = cr.fetchone()[0] return result _columns = { diff --git a/addons/sale/report/shipping.py b/addons/sale/report/shipping.py index 0fa1ed6158a..bddd3a32170 100644 --- a/addons/sale/report/shipping.py +++ b/addons/sale/report/shipping.py @@ -42,7 +42,7 @@ class shipping(report_sxw.rml_parse): "and so.partner_id=rp.id " \ "and so.partner_invoice_id=rpa.id " \ "and rpa.country_id=rc.id " \ - "and sp.id=%d "%(data.id)) + "and sp.id=%s", (data.id,)) add=self.cr.dictfetchall() return add @@ -55,7 +55,7 @@ class shipping(report_sxw.rml_parse): "and so.partner_id=rp.id " \ "and so.partner_shipping_id=rpa.id " \ "and rpa.country_id=rc.id " \ - "and sp.id=%d "%(data.id)) + "and sp.id=%s", (data.id,)) ship=self.cr.dictfetchall() return ship @@ -67,8 +67,8 @@ class shipping(report_sxw.rml_parse): # "LEFT JOIN stock_move sm ON (sp.id = sm.picking_id) "\ # "LEFT JOIN product_product pp ON (sm.product_id = pp.id) "\ # "LEFT JOIN product_template pt ON (pp.product_tmpl_id = pt.id) "\ -# "WHERE sm.picking_id = %d "%(data['id'])) +# "WHERE sm.picking_id = %s", (data['id'],)) # sum_total = self.cr.fetchone()[0] or 0.00 # return True -report_sxw.report_sxw('report.sale.shipping','stock.picking','addons/sale/report/shipping.rml',parser=shipping) \ No newline at end of file +report_sxw.report_sxw('report.sale.shipping','stock.picking','addons/sale/report/shipping.rml',parser=shipping) diff --git a/addons/scrum/report/sprint_burndown.py b/addons/scrum/report/sprint_burndown.py index 1ceeb5a93df..5c2d7f91de1 100644 --- a/addons/scrum/report/sprint_burndown.py +++ b/addons/scrum/report/sprint_burndown.py @@ -49,12 +49,12 @@ class report_tasks(report_int): canv = canvas.init(fname=io, format='pdf') canv.set_author("Tiny ERP") - cr.execute('select id,date_start,date_stop from scrum_sprint where id=%d', (datas['id'],)) + cr.execute('select id,date_start,date_stop from scrum_sprint where id=%s', (datas['id'],)) for (id,date_start,date_stop) in cr.fetchall(): date_to_int = lambda x: int(x.ticks()) int_to_date = lambda x: '/a60{}'+DateTime.localtime(x).strftime('%d/%m/%Y') - cr.execute('select id from project_task where product_backlog_id in(select id from scrum_product_backlog where sprint_id=%d)', (id,)) + cr.execute('select id from project_task where product_backlog_id in(select id from scrum_product_backlog where sprint_id=%s)', (id,)) ids = map(lambda x: x[0], cr.fetchall()) datas = _burndown.compute_burndown(cr, uid, ids, date_start, date_stop) diff --git a/addons/stock/product.py b/addons/stock/product.py index 35e49f5f95e..b43275b7961 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -45,13 +45,13 @@ class product_product(osv.osv): return res if context.get('shop', False): - cr.execute('select warehouse_id from sale_shop where id=%d', (int(context['shop']),)) + cr.execute('select warehouse_id from sale_shop where id=%s', (int(context['shop']),)) res2 = cr.fetchone() if res2: context['warehouse'] = res2[0] if context.get('warehouse', False): - cr.execute('select lot_stock_id from stock_warehouse where id=%d', (int(context['warehouse']),)) + cr.execute('select lot_stock_id from stock_warehouse where id=%s', (int(context['warehouse']),)) res2 = cr.fetchone() if res2: context['location'] = res2[0] diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9d71666b104..4e5463b5245 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -234,9 +234,9 @@ class stock_location(osv.osv): result = [] amount = 0.0 for id in self.search(cr, uid, [('location_id', 'child_of', ids)]): - cr.execute("select product_uom,sum(product_qty) as product_qty from stock_move where location_dest_id=%d and product_id=%d and state='done' group by product_uom", (id,product_id)) + cr.execute("select product_uom,sum(product_qty) as product_qty from stock_move where location_dest_id=%s and product_id=%s and state='done' group by product_uom", (id,product_id)) results = cr.dictfetchall() - cr.execute("select product_uom,-sum(product_qty) as product_qty from stock_move where location_id=%d and product_id=%d and state in ('done', 'assigned') group by product_uom", (id,product_id)) + cr.execute("select product_uom,-sum(product_qty) as product_qty from stock_move where location_id=%s and product_id=%s and state in ('done', 'assigned') group by product_uom", (id,product_id)) results += cr.dictfetchall() total = 0.0 @@ -340,7 +340,7 @@ class stock_picking(osv.osv): sql_str="""update stock_move set date_planned='%s' where - picking_id=%d """ % (value,pick.id) + picking_id=%s """ % (value,pick.id) if pick.min_date: sql_str += " and (date_planned='"+pick.min_date+"' or date_planned<'"+value+"')" cr.execute(sql_str) @@ -800,7 +800,7 @@ stock_production_lot_revision() # class stock_move(osv.osv): def _getSSCC(self, cr, uid, context={}): - cr.execute('select id from stock_tracking where create_uid=%d order by id desc limit 1', (uid,)) + cr.execute('select id from stock_tracking where create_uid=%s order by id desc limit 1', (uid,)) res = cr.fetchone() return (res and res[0]) or False _name = "stock.move" @@ -1030,13 +1030,13 @@ class stock_move(osv.osv): done.append(move.id) pickings[move.picking_id.id] = 1 r = res.pop(0) - cr.execute('update stock_move set location_id=%d, product_qty=%f where id=%d', (r[1],r[0], move.id)) + cr.execute('update stock_move set location_id=%s, product_qty=%s where id=%s', (r[1],r[0], move.id)) while res: r = res.pop(0) move_id = self.copy(cr, uid, move.id, {'product_qty':r[0], 'location_id':r[1]}) done.append(move_id) - #cr.execute('insert into stock_move_history_ids values (%d,%d)', (move.id,move_id)) + #cr.execute('insert into stock_move_history_ids values (%s,%s)', (move.id,move_id)) if done: count += len(done) self.write(cr, uid, done, {'state':'assigned'}) @@ -1084,7 +1084,7 @@ class stock_move(osv.osv): for move in self.browse(cr, uid, ids): if move.move_dest_id.id and (move.state != 'done'): mid = move.move_dest_id.id - cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%d,%d)', (move.id, move.move_dest_id.id)) + cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting','confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state':'assigned'}) if move.move_dest_id.picking_id: diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py index cb98f3ec08e..f0ce60b4c22 100644 --- a/addons/stock/wizard/inventory_merge_zero.py +++ b/addons/stock/wizard/inventory_merge_zero.py @@ -42,11 +42,11 @@ def do_merge(self, cr, uid, data, context): raise wizard.except_wizard("Warning", "Please select one and only one inventory!") - cr.execute('select distinct location_id from stock_inventory_line where inventory_id=%d', (data['ids'][0],)) + cr.execute('select distinct location_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) loc_ids = map(lambda x: x[0], cr.fetchall()) locs = ','.join(map(lambda x: str(x), loc_ids)) - cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%d', (data['ids'][0],)) + cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) inv = cr.fetchall() cr.execute('select distinct product_id from stock_move where (location_dest_id in ('+locs+')) or (location_id in ('+locs+'))')