self.acc_data_dict[account_id] = ids
else:
ids = self.acc_data_dict[account_id]
-
+
+ query_params = (tuple(ids), date1, date2)
if option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id in %s \
- AND date>=%s AND date<=%s AND amount<0",
- (tuple(ids),date1, date2))
+ AND date>=%s AND date<=%s AND amount<0", query_params)
elif option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id in %s \
- AND date>=%s AND date<=%s AND amount>0",
- (tuple(ids), date1, date2))
+ AND date>=%s AND date<=%s AND amount>0", query_params)
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
- WHERE account_id in %s \
- AND date>=%s AND date<=%s",
- (tuple(ids), date1, date2))
+ WHERE account_id in %s \
+ AND date>=%s AND date<=%s", query_params)
return self.cr.fetchone()[0] or 0.0
def _move_sum_balance(self, account_id, date1, date2):
else:
ids2 = self.acc_sum_list
+ query_params = (tuple(ids2), date1, date2)
if option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id IN %s \
- AND date>=%s AND date<=%s AND amount>0",
- (tuple(ids2), date1, date2))
+ AND date>=%s AND date<=%s AND amount>0", query_params)
elif option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id IN %s \
- AND date>=%s AND date<=%s AND amount<0",
- (tuple(ids2), date1, date2))
+ AND date>=%s AND date<=%s AND amount<0", query_params)
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
WHERE account_id IN %s \
- AND date>=%s AND date<=%s",
- (tuple(ids2), date1, date2))
+ AND date>=%s AND date<=%s", query_params)
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
def _sum_debit_period(self, period_id,journal_id=None):
journals = journal_id or self.journal_ids
- if not self.journals:
+ if not journals:
return 0.0
self.cr.execute('SELECT SUM(debit) FROM account_move_line '
'WHERE period_id=%s AND journal_id IN %s '
def _sum_credit_period(self, period_id,journal_id=None):
journals = journal_id or self.journal_ids
- if not self.journals:
+ if not journals:
return 0.0
self.cr.execute('SELECT SUM(credit) FROM account_move_line '
'WHERE period_id=%s AND journal_id IN %s '
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
- cr.execute(sql, (data['form']['date_from']))
+ cr.execute(sql, (data['form']['date_from'],))
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
"WHERE aal.account_id=aaa.id "\
"AND aal.id IN %%s "\
"AND (aal.journal_id %s) "\
- "AND aal.date>=%s "\
- "AND aal.date<=%s "\
+ "AND aal.date>=%%s "\
+ "AND aal.date<=%%s "\
"GROUP BY aal.account_id, aaa.name, aaa.code "\
"ORDER BY aal.account_id" % (
journal_filter
from account_move_line ml
inner join payment_line pl
on (ml.id = pl.move_line_id)
- where pl.id in (%s)"""% self.translate(name),
+ where pl.id in %%s"""% self.translate(name),
(tuple(ids),))
res = dict(cr.fetchall())
query = """
select distinct(answer)
from profile_question_no_rel
- where profile in (%s)"""% ','.join([str(i) for i in ids ])
+ where profile in %s"""
- cr.execute(query)
+ cr.execute(query, (tuple(ids),))
ans_no = [x[0] for x in cr.fetchall()]
return [ans_yes, ans_no]
def _recompute_categ(self, cr, uid, pid, answers_ids):
- ok = []
cr.execute('''
- select r.category_id
+ 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 = %s and (s.exclusif = false or s.exclusif is null)
''', (pid,))
- for x in cr.fetchall():
- ok.append(x[0])
+ categories = [x[0] for x in cr.fetchall()]
query = '''
- select id, categ_id
- from crm_segmentation
- where profiling_active = true'''
- if ok != []:
- query = query + ' and categ_id not in %s'
- query = query + ' order by id '
-
- cr.execute(query, (tuple(ids),))
+ select id, categ_id
+ from crm_segmentation
+ where profiling_active = true'''
+ if not categories:
+ query_params = ()
+ else:
+ query += ' and categ_id not in %s'
+ query_params = (tuple(categories),)
+ query += ' order by id '
+
+ cr.execute(query, query_params)
segm_cat_ids = cr.fetchall()
for (segm_id, cat_id) in segm_cat_ids:
if test_prof(cr, uid, segm_id, pid, answers_ids):
- ok.append(cat_id)
- return ok
+ categories.append(cat_id)
+ return categories
class question(osv.osv):
for id in ids:
res[id] = []
for id in ids:
- query = "select project_id from event_event where id = %i"
+ query = "select project_id from event_event where id = %s"
cr.execute(query, (id,))
project_ids = [ x[0] for x in cr.fetchall()]
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',project_ids),('state','<>','done')], limit=self._limit)
cr.execute('''
SELECT partner_id, id, type
FROM res_partner_address
- WHERE partner_id IN (%s)
+ WHERE partner_id IN %s
''', (tuple(partner_ids),))
fetchal = cr.fetchall()
if not fetchal:
sql_str = """update stock_move set
date_planned=%s
where
- picking_id=%d """
+ picking_id=%s """
sqlargs = (value, pick.id)
if pick.max_date:
location_id in %s
group by
prodlot_id
- having sum(name) ''' + str(args[0][1]) + ' %s'
+ having sum(name) ''' + str(args[0][1]) + ' %s',
(tuple(locations), args[0][2]))
res = cr.fetchall()
ids = [('id', 'in', map(lambda x: x[0], res))]