[IMP]:Account sql queries to parameterized query
bzr revid: nch@tinyerp.com-20091130102422-dgvq2kh7y8dm453q
This commit is contained in:
parent
f247d0f7e3
commit
cf02ffe65f
|
@ -201,20 +201,19 @@ class account_account(osv.osv):
|
|||
}
|
||||
#get all the necessary accounts
|
||||
ids2 = self._get_children_and_consol(cr, uid, ids, context)
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
#compute for each account the balance/debit/credit from the move lines
|
||||
accounts = {}
|
||||
if ids2:
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid,
|
||||
context=context)
|
||||
cr.execute(("SELECT l.account_id as id, " +\
|
||||
cr.execute("SELECT l.account_id as id, " +\
|
||||
' , '.join(map(lambda x: mapping[x], field_names)) +
|
||||
"FROM " \
|
||||
"account_move_line l " \
|
||||
"WHERE " \
|
||||
"l.account_id IN (%s) " \
|
||||
"l.account_id =ANY(%s) " \
|
||||
"AND " + query + " " \
|
||||
"GROUP BY l.account_id") % (acc_set, ))
|
||||
"GROUP BY l.account_id",(ids2,))
|
||||
|
||||
for res in cr.dictfetchall():
|
||||
accounts[res['id']] = res
|
||||
|
@ -329,7 +328,7 @@ class account_account(osv.osv):
|
|||
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
||||
return False
|
||||
while(ids):
|
||||
cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str, ids))+')')
|
||||
cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,))
|
||||
child_ids = filter(None, map(lambda x: x[0], cr.fetchall()))
|
||||
c_ids = child_ids
|
||||
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
||||
|
@ -753,7 +752,7 @@ class account_move(osv.osv):
|
|||
|
||||
def _amount_compute(self, cr, uid, ids, name, args, context, where =''):
|
||||
if not ids: return {}
|
||||
cr.execute('select move_id,sum(debit) from account_move_line where move_id in ('+','.join(map(str,map(int, ids)))+') group by move_id')
|
||||
cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id',(ids,))
|
||||
result = dict(cr.fetchall())
|
||||
for id in ids:
|
||||
result.setdefault(id, 0.0)
|
||||
|
@ -834,7 +833,7 @@ class account_move(osv.osv):
|
|||
if new_name:
|
||||
self.write(cr, uid, [move.id], {'name':new_name})
|
||||
|
||||
cr.execute('update account_move set state=%s where id in ('+','.join(map(str, ids))+')', ('posted',))
|
||||
cr.execute('update account_move set state=%s where id =ANY(%s) ',('posted',ids,))
|
||||
else:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !'))
|
||||
return True
|
||||
|
@ -847,7 +846,7 @@ class account_move(osv.osv):
|
|||
if not line.journal_id.update_posted:
|
||||
raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.'))
|
||||
if len(ids):
|
||||
cr.execute('update account_move set state=%s where id in ('+','.join(map(str, ids))+')', ('draft',))
|
||||
cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
|
||||
return True
|
||||
|
||||
def write(self, cr, uid, ids, vals, context={}):
|
||||
|
@ -1113,23 +1112,22 @@ class account_tax_code(osv.osv):
|
|||
"""
|
||||
def _sum(self, cr, uid, ids, name, args, context, where =''):
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
if context.get('based_on', 'invoices') == 'payments':
|
||||
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
||||
FROM account_move_line AS line, \
|
||||
account_move AS move \
|
||||
LEFT JOIN account_invoice invoice ON \
|
||||
(invoice.move_id = move.id) \
|
||||
WHERE line.tax_code_id in ('+acc_set+') '+where+' \
|
||||
WHERE line.tax_code_id =ANY(%s) '+where+' \
|
||||
AND move.id = line.move_id \
|
||||
AND ((invoice.state = \'paid\') \
|
||||
OR (invoice.id IS NULL)) \
|
||||
GROUP BY line.tax_code_id')
|
||||
GROUP BY line.tax_code_id',(ids2,))
|
||||
else:
|
||||
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
||||
FROM account_move_line AS line \
|
||||
WHERE line.tax_code_id in ('+acc_set+') '+where+' \
|
||||
GROUP BY line.tax_code_id')
|
||||
WHERE line.tax_code_id =ANY(%s) '+where+' \
|
||||
GROUP BY line.tax_code_id',(ids2,))
|
||||
res=dict(cr.fetchall())
|
||||
for record in self.browse(cr, uid, ids, context):
|
||||
def _rec_get(record):
|
||||
|
@ -1204,7 +1202,7 @@ class account_tax_code(osv.osv):
|
|||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from account_tax_code where id in ('+','.join(map(str, ids))+')')
|
||||
cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
|
@ -1824,7 +1822,7 @@ class account_account_template(osv.osv):
|
|||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select parent_id from account_account_template where id in ('+','.join(map(str, ids))+')')
|
||||
cr.execute('select parent_id from account_account_template where id =ANY(%s)',(ids,))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
|
@ -1883,7 +1881,7 @@ class account_tax_code_template(osv.osv):
|
|||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from account_tax_code_template where id in ('+','.join(map(str, ids))+')')
|
||||
cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)',(ids,))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
|
|
|
@ -257,7 +257,7 @@ class account_move_line(osv.osv):
|
|||
cursor.execute('SELECT l.id, i.id ' \
|
||||
'FROM account_move_line l, account_invoice i ' \
|
||||
'WHERE l.move_id = i.move_id ' \
|
||||
'AND l.id in (' + ','.join([str(x) for x in ids]) + ')')
|
||||
'AND l.id =ANY(%s)',(ids,))
|
||||
invoice_ids = []
|
||||
for line_id, invoice_id in cursor.fetchall():
|
||||
res[line_id] = invoice_id
|
||||
|
@ -552,8 +552,6 @@ class account_move_line(osv.osv):
|
|||
return True
|
||||
|
||||
def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context={}):
|
||||
id_set = ','.join(map(str, ids))
|
||||
|
||||
lines = self.browse(cr, uid, ids, context=context)
|
||||
unrec_lines = filter(lambda x: not x['reconcile_id'], lines)
|
||||
credit = debit = 0.0
|
||||
|
@ -578,10 +576,10 @@ class account_move_line(osv.osv):
|
|||
|
||||
cr.execute('SELECT account_id, reconcile_id \
|
||||
FROM account_move_line \
|
||||
WHERE id IN ('+id_set+') \
|
||||
GROUP BY account_id,reconcile_id')
|
||||
WHERE id =ANY(%s) \
|
||||
GROUP BY account_id,reconcile_id',(ids,))
|
||||
r = cr.fetchall()
|
||||
#TODO: move this check to a constraint in the account_move_reconcile object
|
||||
#TODO: move this check to a constraint in the account_move_reconcile object
|
||||
if (len(r) != 1) and not context.get('fy_closing', False):
|
||||
raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! '))
|
||||
if not unrec_lines:
|
||||
|
|
|
@ -90,20 +90,20 @@ class res_partner(osv.osv):
|
|||
_description = 'Partner'
|
||||
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context):
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("""select
|
||||
cr.execute("""select
|
||||
l.partner_id, a.type, sum(l.debit-l.credit)
|
||||
from
|
||||
account_move_line l
|
||||
left join
|
||||
account_account a on (l.account_id=a.id)
|
||||
where
|
||||
a.type in ('receivable','payable') and
|
||||
l.partner_id in (%s) and
|
||||
a.type =ANY(%s) and
|
||||
l.partner_id =ANY(%s) and
|
||||
l.reconcile_id is null and
|
||||
""" % (','.join(map(str, ids)),))+query+"""
|
||||
"""+query+"""
|
||||
group by
|
||||
l.partner_id, a.type
|
||||
""")
|
||||
""",(['receivable','payable'],ids,))
|
||||
tinvert = {
|
||||
'credit': 'receivable',
|
||||
'debit': 'payable'
|
||||
|
|
|
@ -34,7 +34,6 @@ class account_analytic_account(osv.osv):
|
|||
_description = 'Analytic Accounts'
|
||||
|
||||
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
acc_set = ",".join(map(str, ids))
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
|
@ -42,7 +41,7 @@ class account_analytic_account(osv.osv):
|
|||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount<0 and a.id =ANY(%s) GROUP BY a.id",(ids,))
|
||||
r = dict(cr.fetchall())
|
||||
for i in ids:
|
||||
r.setdefault(i,0.0)
|
||||
|
@ -50,15 +49,13 @@ class account_analytic_account(osv.osv):
|
|||
|
||||
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
|
||||
acc_set = ",".join(map(str, ids))
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount>0 and a.id =ANY(%s) GROUP BY a.id" ,(ids,))
|
||||
r= dict(cr.fetchall())
|
||||
for i in ids:
|
||||
r.setdefault(i,0.0)
|
||||
|
@ -67,12 +64,11 @@ class account_analytic_account(osv.osv):
|
|||
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
res = {}
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
|
||||
for i in ids:
|
||||
res.setdefault(i,0.0)
|
||||
|
||||
if not acc_set:
|
||||
if not ids2:
|
||||
return res
|
||||
|
||||
where_date = ''
|
||||
|
@ -81,12 +77,12 @@ class account_analytic_account(osv.osv):
|
|||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id =ANY(%s) GROUP BY a.id",(ids2,))
|
||||
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
|
||||
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set)
|
||||
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id =ANY(%s)",(ids2,))
|
||||
|
||||
currency= dict(cr.fetchall())
|
||||
|
||||
|
@ -131,7 +127,7 @@ class account_analytic_account(osv.osv):
|
|||
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
||||
FROM account_analytic_account a \
|
||||
LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \
|
||||
WHERE a.id IN ('+acc_set+') GROUP BY a.id')
|
||||
WHERE a.id =ANY(%s) GROUP BY a.id',(ids2,))
|
||||
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
|
|
|
@ -110,19 +110,18 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
|
||||
if option == "credit" :
|
||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||
AND date>=%s AND date<=%s AND amount<0",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
|
||||
(ids,date1, date2))
|
||||
elif option == "debit" :
|
||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||
WHERE account_id =ANY(%s)\
|
||||
AND date>=%s AND date<=%s AND amount>0",
|
||||
(date1, date2))
|
||||
(ids,date1, date2))
|
||||
elif option == "quantity" :
|
||||
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||
WHERE account_id =ANY(%s)\
|
||||
AND date>=%s AND date<=%s",
|
||||
(date1, date2))
|
||||
(ids,date1, date2))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
|
||||
|
@ -166,7 +165,6 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
|
||||
def _sum_all(self, accounts, date1, date2, option):
|
||||
ids = map(lambda x: x['id'], accounts)
|
||||
|
||||
if not len(ids):
|
||||
return 0.0
|
||||
|
||||
|
@ -176,22 +174,18 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
self.acc_sum_list = ids2
|
||||
else:
|
||||
ids2 = self.acc_sum_list
|
||||
|
||||
if option == "debit" :
|
||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||
AND date>=%s AND date<=%s AND amount>0",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0",
|
||||
(ids,date1, date2,))
|
||||
elif option == "credit" :
|
||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||
AND date>=%s AND date<=%s AND amount<0",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
|
||||
(ids,date1, date2,))
|
||||
elif option == "quantity" :
|
||||
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||
AND date>=%s AND date<=%s",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s)AND date>=%s AND date<=%s",
|
||||
(ids,date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ class account_analytic_analytic_check(report_sxw.rml_parse):
|
|||
def _lines_p(self, date1, date2):
|
||||
res = []
|
||||
acc_obj = self.pool.get('account.account')
|
||||
# print"3333333acc_obj3333333",acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','user_type'])
|
||||
|
||||
for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code']):
|
||||
self.cr.execute("SELECT sum(debit), sum(credit) \
|
||||
|
|
|
@ -93,7 +93,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse):
|
|||
ids = map(lambda x: x.id, accounts)
|
||||
if not len(ids):
|
||||
return 0.0
|
||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids, date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_credit(self, accounts, date1, date2):
|
||||
|
@ -101,7 +101,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse):
|
|||
if not len(ids):
|
||||
return 0.0
|
||||
ids = map(lambda x: x.id, accounts)
|
||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_balance(self, accounts, date1, date2):
|
||||
|
|
|
@ -40,8 +40,8 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
|
|||
ids = map(lambda x: x.id, accounts)
|
||||
self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \
|
||||
FROM account_analytic_line AS aal, account_account AS aa \
|
||||
WHERE (aal.general_account_id=aa.id) AND (aal.account_id IN ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) AND aa.active \
|
||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2))
|
||||
WHERE (aal.general_account_id=aa.id) AND (aal.account_id =ANY(%s)) AND (date>=%s) AND (date<=%s) AND aa.active \
|
||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,))
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
for r in res:
|
||||
|
@ -60,8 +60,8 @@ 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=%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))
|
||||
WHERE aal.account_id=aaa.id AND aal.account_id =ANY(%s) 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", (ids,general_account_id, date1, date2,))
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
aaa_obj = self.pool.get('account.analytic.account')
|
||||
|
@ -86,14 +86,14 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
|
|||
ids = map(lambda x: x.id, accounts)
|
||||
self.cr.execute("SELECT sum(amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_credit(self, accounts, date1, date2):
|
||||
ids = map(lambda x: x.id, accounts)
|
||||
self.cr.execute("SELECT -sum(amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_balance(self, accounts, date1, date2):
|
||||
|
@ -105,7 +105,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
|
|||
ids = map(lambda x: x.id, accounts)
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False)
|
||||
|
|
|
@ -52,10 +52,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
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 (" +
|
||||
','.join(map(str, journal_ids)) + ")) \
|
||||
AND (aal.journal_id =ANY(%s) ) \
|
||||
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
||||
(account_id, date1, date2))
|
||||
(account_id, date1, date2,journal_ids))
|
||||
res = self.cr.dictfetchall()
|
||||
return res
|
||||
|
||||
|
@ -80,10 +79,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
account_analytic_journal AS aaj \
|
||||
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)) + ")) \
|
||||
ORDER BY aal.date, aaj.code, aal.code",
|
||||
(general_account_id, account_id, date1, date2))
|
||||
AND (aal.journal_id=aaj.id) AND (aaj.id =ANY(%s)) \
|
||||
ORDER BY aal.date, aaj.code, aal.code",
|
||||
(general_account_id, account_id, date1, date2,journal_ids,))
|
||||
res = self.cr.dictfetchall()
|
||||
return res
|
||||
|
||||
|
@ -98,9 +96,8 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id = %s AND date >= %s AND date <= %s \
|
||||
AND journal_id IN (" +
|
||||
','.join(map(str, journal_ids)) + ")",
|
||||
(account_id, date1, date2))
|
||||
AND journal_id =ANY(%s)",
|
||||
(account_id, date1, date2,journal_ids,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_quantity(self, accounts, date1, date2, journals):
|
||||
|
@ -110,18 +107,14 @@ 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 IN (" +
|
||||
','.join(map(str, ids)) + ") AND date>=%s AND date<=%s",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s",
|
||||
(date1, date2,ids,))
|
||||
else:
|
||||
journal_ids = journals[0][2]
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id IN (" +
|
||||
','.join(map(str, ids)) + ") AND date >= %s AND date <= %s \
|
||||
AND journal_id IN (" +
|
||||
','.join(map(str, journal_ids)) + ")",
|
||||
(date1, date2))
|
||||
WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \
|
||||
AND journal_id =ANY(%s)",(ids,date1, date2,journal_ids))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',
|
||||
|
|
|
@ -57,8 +57,8 @@ class account_balance(report_sxw.rml_parse):
|
|||
def get_periods(self, form):
|
||||
result=''
|
||||
if form.has_key('periods') and form['periods'][0][2]:
|
||||
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
|
||||
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
|
||||
period_ids = form['periods'][0][2]
|
||||
self.cr.execute("select name from account_period where id =ANY(%s)" ,(period_ids))
|
||||
res = self.cr.fetchall()
|
||||
len_res = len(res)
|
||||
for r in res:
|
||||
|
|
|
@ -47,11 +47,11 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
def _get_lines(self, form):
|
||||
|
||||
if (form['result_selection'] == 'customer' ):
|
||||
self.ACCOUNT_TYPE = "('receivable')"
|
||||
self.ACCOUNT_TYPE = ['receivable']
|
||||
elif (form['result_selection'] == 'supplier'):
|
||||
self.ACCOUNT_TYPE = "('payable')"
|
||||
self.ACCOUNT_TYPE = ['payable']
|
||||
else:
|
||||
self.ACCOUNT_TYPE = "('payable','receivable')"
|
||||
self.ACCOUNT_TYPE = ['payable','receivable']
|
||||
|
||||
|
||||
res = []
|
||||
|
@ -63,10 +63,10 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
FROM res_partner,account_move_line AS line, account_account
|
||||
WHERE (line.account_id=account_account.id)
|
||||
AND ((reconcile_id IS NULL)
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' )))
|
||||
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 = %s)
|
||||
ORDER BY res_partner.name""" % (form['date1'],form['company_id']))
|
||||
ORDER BY res_partner.name""" , (form['date1'],form['company_id']))
|
||||
partners = self.cr.dictfetchall()
|
||||
## mise a 0 du total
|
||||
for i in range(7):
|
||||
|
@ -74,20 +74,20 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
#
|
||||
|
||||
# Build a string like (1,2,3) for easy use in SQL query
|
||||
partner_ids = '(' + ','.join( [str(x['id']) for x in partners] ) + ')'
|
||||
partner_ids = [x['id'] for x in partners]
|
||||
|
||||
# This dictionary will store the debit-credit for all partners, using partner_id as key.
|
||||
totals = {}
|
||||
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||
FROM account_move_line AS line, account_account
|
||||
WHERE (line.account_id = account_account.id)
|
||||
AND (account_account.type IN %s)
|
||||
AND (partner_id in %s)
|
||||
AND (account_account.type =ANY(%s))
|
||||
AND (partner_id =ANY (%s))
|
||||
AND ((reconcile_id IS NULL)
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' )))
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
||||
AND (account_account.company_id = %s)
|
||||
AND account_account.active
|
||||
GROUP BY partner_id""" % (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id']))
|
||||
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'],))
|
||||
t = self.cr.fetchall()
|
||||
for i in t:
|
||||
totals[i[0]] = i[1]
|
||||
|
@ -98,14 +98,14 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||
FROM account_move_line AS line, account_account
|
||||
WHERE (line.account_id=account_account.id)
|
||||
AND (account_account.type IN %s)
|
||||
AND (COALESCE(date_maturity,date) < '%s')
|
||||
AND (partner_id in %s)
|
||||
AND (account_account.type =ANY (%s))
|
||||
AND (COALESCE(date_maturity,date) < %s)
|
||||
AND (partner_id =ANY (%s))
|
||||
AND ((reconcile_id IS NULL)
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' )))
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
||||
AND (account_account.company_id = %s)
|
||||
AND account_account.active
|
||||
GROUP BY partner_id"""% (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id']))
|
||||
GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'],))
|
||||
t = self.cr.fetchall()
|
||||
for i in t:
|
||||
future_past[i[0]] = i[1]
|
||||
|
@ -113,14 +113,14 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||
FROM account_move_line AS line, account_account
|
||||
WHERE (line.account_id=account_account.id)
|
||||
AND (account_account.type IN %s)
|
||||
AND (COALESCE(date_maturity,date) > '%s')
|
||||
AND (partner_id in %s)
|
||||
AND (account_account.type =ANY (%s))
|
||||
AND (COALESCE(date_maturity,date) > %s)
|
||||
AND (partner_id =ANY (%s))
|
||||
AND ((reconcile_id IS NULL)
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' )))
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
||||
AND (account_account.company_id = %s)
|
||||
AND account_account.active
|
||||
GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id']))
|
||||
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'],))
|
||||
t = self.cr.fetchall()
|
||||
for i in t:
|
||||
future_past[i[0]] = i[1]
|
||||
|
@ -132,14 +132,14 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||
FROM account_move_line AS line, account_account
|
||||
WHERE (line.account_id=account_account.id)
|
||||
AND (account_account.type IN %s)
|
||||
AND (COALESCE(date_maturity,date) BETWEEN '%s' AND '%s')
|
||||
AND (partner_id in %s )
|
||||
AND (account_account.type =ANY (%s))
|
||||
AND (COALESCE(date_maturity,date) BETWEEN %s AND %s)
|
||||
AND (partner_id =ANY (%s))
|
||||
AND ((reconcile_id IS NULL)
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' )))
|
||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
||||
AND (account_account.company_id = %s)
|
||||
AND account_account.active
|
||||
GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id']))
|
||||
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'],))
|
||||
|
||||
t = self.cr.fetchall()
|
||||
d = {}
|
||||
|
|
|
@ -41,10 +41,10 @@ class journal_print(report_sxw.rml_parse):
|
|||
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
super(journal_print, self).set_context(objects, data, ids, report_type)
|
||||
self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')')
|
||||
self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)',(ids,))
|
||||
res = self.cr.fetchall()
|
||||
self.period_ids = ','.join([str(x[0]) for x in res])
|
||||
self.journal_ids = ','.join([str(x[1]) for x in res])
|
||||
self.period_ids = map(lambda x:x[0],res)
|
||||
self.journal_ids = map(lambda x:x[1],res)
|
||||
|
||||
# returns a list of period objs
|
||||
def periods(self, journal_period_objs):
|
||||
|
@ -74,7 +74,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=%s 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 =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period,journal_id,))
|
||||
res = self.cr.dictfetchall()
|
||||
res[0].update({'period_name':period_data.name})
|
||||
res[0].update({'pid':period})
|
||||
|
@ -82,45 +82,45 @@ 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=%s 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 =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,self.journal_ids,))
|
||||
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=%s 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 =ANY(%s) and state<>\'draft\'', (period_id,journal_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=%s 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 =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,))
|
||||
|
||||
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=%s 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 =ANY(%s) and state<>\'draft\'', (period_id,journal_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=%s 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 =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_debit(self,period_id=None,journal_id=None):
|
||||
if type(period_id)==type([]):
|
||||
self.cr.execute('select sum(debit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'')
|
||||
self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
if not self.journal_ids or not self.period_ids:
|
||||
return 0.0
|
||||
self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
||||
self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _sum_credit(self,period_id=None,journal_id=None):
|
||||
if type(period_id)==type([]):
|
||||
self.cr.execute('select sum(credit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'')
|
||||
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
if not self.journal_ids or not self.period_ids:
|
||||
return 0.0
|
||||
self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
||||
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)
|
||||
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False)
|
||||
|
|
|
@ -89,7 +89,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
# We have the account ID we will search all account move line from now until this time
|
||||
# We are in the case of we are on the top of the account move Line
|
||||
cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\
|
||||
where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id )
|
||||
where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,))
|
||||
res_mv = cr.dictfetchall()
|
||||
# we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line
|
||||
if (len(res_mv) >=1):
|
||||
|
@ -120,15 +120,11 @@ class general_ledger(rml_parse.rml_parse):
|
|||
## This function will return the most aged date
|
||||
periods = form['periods'][0][2]
|
||||
if not periods:
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
|
||||
"""
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],))
|
||||
else:
|
||||
periods_id = ','.join(map(str, periods))
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
|
||||
"""
|
||||
self.cr.execute(sql)
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,))
|
||||
res = self.cr.dictfetchall()
|
||||
borne_min = res[0]['start_date']
|
||||
borne_max = res[0]['stop_date']
|
||||
|
@ -138,15 +134,11 @@ class general_ledger(rml_parse.rml_parse):
|
|||
elif form['state'] == 'all':
|
||||
periods = form['periods'][0][2]
|
||||
if not periods:
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
|
||||
"""
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],))
|
||||
else:
|
||||
periods_id = ','.join(map(str, periods))
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
|
||||
"""
|
||||
self.cr.execute(sql)
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,))
|
||||
res = self.cr.dictfetchall()
|
||||
period_min = res[0]['start_date']
|
||||
period_max = res[0]['stop_date']
|
||||
|
@ -230,8 +222,8 @@ class general_ledger(rml_parse.rml_parse):
|
|||
else:
|
||||
## We will now compute solde initiaux
|
||||
for move in res:
|
||||
SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'"
|
||||
self.cr.execute(SOLDEINIT)
|
||||
self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \
|
||||
WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date']))
|
||||
resultat = self.cr.dictfetchall()
|
||||
if resultat[0] :
|
||||
if resultat[0]['sum_debit'] == None:
|
||||
|
@ -284,7 +276,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
for l in res:
|
||||
line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id'])
|
||||
l['move'] = line.move_id.name
|
||||
self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
|
||||
self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,))
|
||||
tmpres = self.cr.dictfetchall()
|
||||
if len(tmpres) > 0 :
|
||||
inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id'])
|
||||
|
@ -312,7 +304,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
|
||||
"WHERE l.account_id = %s AND "+self.query,(account.id,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -326,7 +318,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id,self.query))
|
||||
"WHERE l.account_id = %s AND "+ self.query,(account.id,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -340,7 +332,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
def _sum_solde_account(self, account, form):
|
||||
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s"%(account.id,self.query))
|
||||
"WHERE l.account_id = %s AND "+ self.query,(account.id,))
|
||||
sum_solde = self.cr.fetchone()[0] or 0.0
|
||||
if form.get('soldeinit', False):
|
||||
sum_solde += account.init_debit - account.init_credit
|
||||
|
@ -352,7 +344,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,))
|
||||
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||
return sum_debit
|
||||
|
||||
|
@ -361,7 +353,7 @@ class general_ledger(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -372,14 +364,14 @@ class general_ledger(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,))
|
||||
sum_solde = self.cr.fetchone()[0] or 0.0
|
||||
return sum_solde
|
||||
|
||||
def _set_get_account_currency_code(self, account_id):
|
||||
self.cr.execute("SELECT c.code as code "\
|
||||
"FROM res_currency c,account_account as ac "\
|
||||
"WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id))
|
||||
"WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,))
|
||||
result = self.cr.fetchone()
|
||||
if result:
|
||||
self.account_currency = result[0]
|
||||
|
|
|
@ -83,14 +83,14 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
#
|
||||
#
|
||||
result[account_line.id] = ' '
|
||||
num_id_move = str(account_line.move_id.id)
|
||||
num_id_line = str(account_line.id)
|
||||
account_id = str(account_line.account_id.id)
|
||||
num_id_move = account_line.move_id.id
|
||||
num_id_line = account_line.id
|
||||
account_id = account_line.account_id.id
|
||||
# search the basic account
|
||||
# We have the account ID we will search all account move line from now until this time
|
||||
# We are in the case of we are on the top of the account move Line
|
||||
cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\
|
||||
where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id )
|
||||
where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,))
|
||||
res_mv = cr.dictfetchall()
|
||||
# we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line
|
||||
if (len(res_mv) >=1):
|
||||
|
@ -121,15 +121,12 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
## This function will return the most aged date
|
||||
periods = form['periods'][0][2]
|
||||
if not periods:
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
|
||||
"""
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],))
|
||||
else:
|
||||
periods_id = ','.join(map(str, periods))
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
|
||||
"""
|
||||
self.cr.execute(sql)
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,))
|
||||
|
||||
res = self.cr.dictfetchall()
|
||||
borne_min = res[0]['start_date']
|
||||
borne_max = res[0]['stop_date']
|
||||
|
@ -139,15 +136,12 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
elif form['state'] == 'all':
|
||||
periods = form['periods'][0][2]
|
||||
if not periods:
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
|
||||
"""
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = = %s""" ,(form['fiscalyear'],))
|
||||
|
||||
else:
|
||||
periods_id = ','.join(map(str, periods))
|
||||
sql = """
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
|
||||
"""
|
||||
self.cr.execute(sql)
|
||||
self.cr.execute("""
|
||||
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,))
|
||||
res = self.cr.dictfetchall()
|
||||
period_min = res[0]['start_date']
|
||||
period_max = res[0]['stop_date']
|
||||
|
@ -178,8 +172,6 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
|
||||
|
||||
def get_children_accounts(self, account, form):
|
||||
|
||||
print self.ids
|
||||
self.child_ids = self.pool.get('account.account').search(self.cr, self.uid,
|
||||
[('parent_id', 'child_of', self.ids)])
|
||||
#
|
||||
|
@ -233,8 +225,8 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
else:
|
||||
## We will now compute solde initiaux
|
||||
for move in res:
|
||||
SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'"
|
||||
self.cr.execute(SOLDEINIT)
|
||||
self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \
|
||||
WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date']))
|
||||
resultat = self.cr.dictfetchall()
|
||||
if resultat[0] :
|
||||
if resultat[0]['sum_debit'] == None:
|
||||
|
@ -287,7 +279,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
for l in res:
|
||||
line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id'])
|
||||
l['move'] = line.move_id.name
|
||||
self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
|
||||
self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,))
|
||||
tmpres = self.cr.dictfetchall()
|
||||
if len(tmpres) > 0 :
|
||||
inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id'])
|
||||
|
@ -315,7 +307,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
|
||||
"WHERE l.account_id = %s AND "+self.query,(account.id,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -329,7 +321,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id,self.query))
|
||||
"WHERE l.account_id = %s AND "+self.query,(account.id,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -343,7 +335,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
def _sum_solde_account(self, account, form):
|
||||
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s"%(account.id,self.query))
|
||||
"WHERE l.account_id = %s AND "+self.query,(account.id,))
|
||||
sum_solde = self.cr.fetchone()[0] or 0.0
|
||||
if form.get('soldeinit',False):
|
||||
sum_solde += account.init_debit - account.init_credit
|
||||
|
@ -355,7 +347,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,))
|
||||
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||
return sum_debit
|
||||
|
||||
|
@ -364,7 +356,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,))
|
||||
## Add solde init to the result
|
||||
#
|
||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||
|
@ -375,14 +367,14 @@ class general_ledger_landscape(rml_parse.rml_parse):
|
|||
return 0.0
|
||||
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
|
||||
"WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,))
|
||||
sum_solde = self.cr.fetchone()[0] or 0.0
|
||||
return sum_solde
|
||||
|
||||
def _set_get_account_currency_code(self, account_id):
|
||||
self.cr.execute("SELECT c.code as code "\
|
||||
"FROM res_currency c,account_account as ac "\
|
||||
"WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id))
|
||||
"WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,))
|
||||
result = self.cr.fetchone()
|
||||
if result:
|
||||
self.account_currency = result[0]
|
||||
|
|
|
@ -166,27 +166,26 @@ class partner_balance(report_sxw.rml_parse):
|
|||
##
|
||||
self.date_lst_string =''
|
||||
if self.date_lst:
|
||||
self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\''
|
||||
|
||||
self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\''
|
||||
|
||||
## Compute Code
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
#
|
||||
if (data['form']['result_selection'] == 'customer' ):
|
||||
self.ACCOUNT_TYPE = "('receivable')"
|
||||
self.ACCOUNT_TYPE = ['receivable']
|
||||
elif (data['form']['result_selection'] == 'supplier'):
|
||||
self.ACCOUNT_TYPE = "('payable')"
|
||||
self.ACCOUNT_TYPE = ['payable']
|
||||
else:
|
||||
self.ACCOUNT_TYPE = "('payable','receivable')"
|
||||
self.ACCOUNT_TYPE = ['payable','receivable']
|
||||
#
|
||||
self.cr.execute("SELECT a.id " \
|
||||
"FROM account_account a " \
|
||||
"LEFT JOIN account_account_type t " \
|
||||
"ON (a.type = t.code) " \
|
||||
"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()])
|
||||
"AND a.type =ANY(%s) "\
|
||||
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,))
|
||||
self.account_ids = [a for (a,) in self.cr.fetchall()]
|
||||
|
||||
super(partner_balance, self).set_context(objects, data, ids, report_type)
|
||||
|
||||
|
@ -214,11 +213,11 @@ class partner_balance(report_sxw.rml_parse):
|
|||
") AS enlitige " \
|
||||
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
||||
"JOIN account_account ac ON (l.account_id = ac.id)" \
|
||||
"WHERE ac.type IN " + self.ACCOUNT_TYPE + " " \
|
||||
"WHERE ac.type =ANY(%s) "
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"AND ac.company_id = "+ str(data['form']['company_id']) +" " \
|
||||
"AND ac.company_id = %s" \
|
||||
"GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
|
||||
"ORDER BY l.account_id,p.name")
|
||||
"ORDER BY l.account_id,p.name",(self.ACCOUNT_TYPE,data['form']['company_id'],))
|
||||
res = self.cr.dictfetchall()
|
||||
for r in res:
|
||||
full_account.append(r)
|
||||
|
@ -355,8 +354,8 @@ class partner_balance(report_sxw.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " )
|
||||
"WHERE l.account_id =ANY(%s)" \
|
||||
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
result_tmp = result_tmp + temp_res
|
||||
|
||||
|
@ -373,8 +372,8 @@ class partner_balance(report_sxw.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " )
|
||||
"WHERE l.account_id =ANY(%s)" \
|
||||
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
result_tmp = result_tmp + temp_res
|
||||
|
||||
|
@ -390,9 +389,9 @@ class partner_balance(report_sxw.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(debit-credit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"AND l.blocked=TRUE " )
|
||||
"WHERE l.account_id =ANY(%s)" \
|
||||
"AND l.date IN (" + self.date_lst_string + ")"\
|
||||
"AND l.blocked=TRUE " ,(self.account_ids,))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
result_tmp = result_tmp + temp_res
|
||||
|
||||
|
@ -411,9 +410,9 @@ class partner_balance(report_sxw.rml_parse):
|
|||
"ELSE 0 " \
|
||||
"END " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"GROUP BY l.partner_id")
|
||||
"WHERE l.account_id =ANY(%s)" \
|
||||
"AND l.date IN (" + self.date_lst_string + ")" \
|
||||
"GROUP BY l.partner_id",(self.account_ids,))
|
||||
a = self.cr.fetchone()[0]
|
||||
|
||||
if self.cr.fetchone() != None:
|
||||
|
@ -438,9 +437,9 @@ class partner_balance(report_sxw.rml_parse):
|
|||
"ELSE 0 " \
|
||||
"END " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"GROUP BY l.partner_id")
|
||||
"WHERE l.account_id =ANY(%s)" \
|
||||
"AND l.date IN (" + self.date_lst_string + ")" \
|
||||
"GROUP BY l.partner_id",(self.account_ids,))
|
||||
a = self.cr.fetchone()[0] or 0.0
|
||||
|
||||
if self.cr.fetchone() != None:
|
||||
|
|
|
@ -50,7 +50,7 @@ class tax_report(rml_parse.rml_parse):
|
|||
else :
|
||||
self.cr.execute ("select id from account_fiscalyear")
|
||||
fy = self.cr.fetchall()
|
||||
self.cr.execute ("select id from account_period where fiscalyear_id = %d"%(fy[0][0]))
|
||||
self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],))
|
||||
periods = self.cr.fetchall()
|
||||
for p in periods :
|
||||
period_list[0][2].append(p[0])
|
||||
|
@ -89,7 +89,6 @@ class tax_report(rml_parse.rml_parse):
|
|||
|
||||
def _get_general(self, tax_code_id,period_list ,company_id, based_on):
|
||||
res=[]
|
||||
period_sql_list = ','.join(map(str, period_list[0][2]))
|
||||
if based_on == 'payments':
|
||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
||||
SUM(line.debit) AS debit, \
|
||||
|
@ -108,11 +107,11 @@ class tax_report(rml_parse.rml_parse):
|
|||
AND line.account_id = account.id \
|
||||
AND account.company_id = %s \
|
||||
AND move.id = line.move_id \
|
||||
AND line.period_id IN ('+ period_sql_list +') \
|
||||
AND line.period_id =ANY(%s) \
|
||||
AND ((invoice.state = %s) \
|
||||
OR (invoice.id IS NULL)) \
|
||||
GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
|
||||
company_id, 'paid'))
|
||||
company_id, period_list[0][2],'paid',))
|
||||
|
||||
else :
|
||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
||||
|
@ -128,10 +127,10 @@ class tax_report(rml_parse.rml_parse):
|
|||
AND line.tax_code_id = %s \
|
||||
AND line.account_id = account.id \
|
||||
AND account.company_id = %s \
|
||||
AND line.period_id IN ('+ period_sql_list +') \
|
||||
AND line.period_id =ANY(%s)\
|
||||
AND account.active \
|
||||
GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
|
||||
company_id))
|
||||
company_id,period_list[0][2],))
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
#AND line.period_id IN ('+ period_sql_list +') \
|
||||
|
|
|
@ -142,7 +142,8 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
if (data['model'] == 'res.partner'):
|
||||
## Si on imprime depuis les partenaires
|
||||
if ids:
|
||||
PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")"
|
||||
#PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")"
|
||||
PARTNER_REQUEST = "AND line.partner_id =ANY(%s)" %ids
|
||||
# Transformation des date
|
||||
#
|
||||
#
|
||||
|
@ -166,11 +167,11 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
#
|
||||
#new_ids = [id for (id,) in self.cr.fetchall()]
|
||||
if data['form']['result_selection'] == 'supplier':
|
||||
self.ACCOUNT_TYPE = "('receivable')"
|
||||
self.ACCOUNT_TYPE = ['receivable']
|
||||
elif data['form']['result_selection'] == 'customer':
|
||||
self.ACCOUNT_TYPE = "('payable')"
|
||||
self.ACCOUNT_TYPE = ['payable']
|
||||
elif data['form']['result_selection'] == 'all':
|
||||
self.ACCOUNT_TYPE = "('payable','receivable')"
|
||||
self.ACCOUNT_TYPE = ['payable','receivable']
|
||||
|
||||
self.cr.execute(
|
||||
"SELECT a.id " \
|
||||
|
@ -178,9 +179,9 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"LEFT JOIN account_account_type t " \
|
||||
"ON (a.type=t.code) " \
|
||||
"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()])
|
||||
'AND a.type =ANY(%s)' \
|
||||
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,))
|
||||
self.account_ids = [a for (a,) in self.cr.fetchall()]
|
||||
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
partner_to_use = []
|
||||
|
@ -195,11 +196,11 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"AND line.date >= %s " \
|
||||
"AND line.date <= %s " \
|
||||
"AND line.reconcile_id IS NULL " \
|
||||
"AND line.account_id IN (" + self.account_ids + ") " \
|
||||
"AND line.account_id =ANY(%s)" \
|
||||
" " + PARTNER_REQUEST + " " \
|
||||
"AND account.company_id = %s " \
|
||||
"AND account.active " ,
|
||||
(self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id']))
|
||||
(self.date_lst[0],self.date_lst[len(self.date_lst)-1],self.account_ids,data['form']['company_id'],))
|
||||
# else:
|
||||
#
|
||||
# self.cr.execute(
|
||||
|
@ -220,7 +221,8 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
partner_to_use.append(res_line['partner_id'])
|
||||
new_ids = partner_to_use
|
||||
|
||||
self.partner_ids = ','.join(map(str, new_ids))
|
||||
#self.partner_ids = ','.join(map(str, new_ids))
|
||||
self.partner_ids = new_ids
|
||||
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
||||
super(third_party_ledger, self).set_context(objects, data, new_ids, report_type)
|
||||
|
||||
|
@ -259,11 +261,11 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"LEFT JOIN account_journal j " \
|
||||
"ON (l.journal_id = j.id) " \
|
||||
"WHERE l.partner_id = %s " \
|
||||
"AND l.account_id IN (" + self.account_ids + ") " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"AND l.account_id =ANY(%s)"\
|
||||
"AND l.date IN (" + self.date_lst_string + ")"
|
||||
" " + RECONCILE_TAG + " "\
|
||||
"ORDER BY l.id",
|
||||
(partner.id,))
|
||||
(partner.id,self.account_ids,))
|
||||
res = self.cr.dictfetchall()
|
||||
sum = 0.0
|
||||
for r in res:
|
||||
|
@ -286,10 +288,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id = %s " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"AND account_id =ANY(%s)" \
|
||||
"AND reconcile_id IS NULL " \
|
||||
"AND date < %s " ,
|
||||
(partner.id, self.date_lst[0],))
|
||||
(partner.id, self.account_ids,self.date_lst[0],))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
@ -301,10 +303,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id = %s " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"AND account_id =ANY(%s)" \
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") " ,
|
||||
(partner.id,))
|
||||
"AND date IN (" + self.date_lst_string + ")" ,
|
||||
(partner.id,self.account_ids,))
|
||||
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
|
@ -325,10 +327,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id=%s " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"AND account_id =ANY(%s)" \
|
||||
"AND reconcile_id IS NULL " \
|
||||
"AND date < %s " ,
|
||||
(partner.id,self.date_lst[0],))
|
||||
(partner.id,self.account_ids,self.date_lst[0],))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
@ -340,10 +342,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id=%s " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"AND account_id =ANY(%s)" \
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") " ,
|
||||
(partner.id,))
|
||||
"AND date IN (" + self.date_lst_string + ")",
|
||||
(partner.id,self.account_ids,))
|
||||
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
|
@ -365,11 +367,11 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"WHERE partner_id =ANY(%s)" \
|
||||
"AND account_id =ANY(%s)" \
|
||||
"AND reconcile_id IS NULL " \
|
||||
"AND date < %s " ,
|
||||
(self.date_lst[0],))
|
||||
(self.partner_ids,self.account_ids,self.date_lst[0],))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
@ -380,12 +382,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"WHERE partner_id =ANY(%s)" \
|
||||
"AND account_id =ANY(%s)" \
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") "
|
||||
)
|
||||
|
||||
"AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
@ -408,11 +408,11 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"WHERE partner_id =ANY(%s)" \
|
||||
"AND account_id =ANY(%s)" \
|
||||
"AND reconcile_id IS NULL " \
|
||||
"AND date < %s " ,
|
||||
(self.date_lst[0],))
|
||||
(self.partner_ids,self.account_ids,self.date_lst[0],))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
@ -423,11 +423,10 @@ class third_party_ledger(rml_parse.rml_parse):
|
|||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||
"AND account_id IN (" + self.account_ids + ") " \
|
||||
"WHERE partner_id =ANY(%s)" \
|
||||
"AND account_id =ANY(%s)" \
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") "
|
||||
)
|
||||
"AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,))
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
|
|
|
@ -111,8 +111,8 @@ class wizard_report(wizard.interface):
|
|||
|
||||
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 """%(data['form']['date_from'])
|
||||
cr.execute(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'],))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
|
||||
|
|
|
@ -56,9 +56,7 @@ def _data_save(self, cr, uid, data, context):
|
|||
|
||||
fy_id = data['form']['fy_id']
|
||||
period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)])
|
||||
fy_period_set = ','.join(map(str, period_ids))
|
||||
periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])])
|
||||
fy2_period_set = ','.join(map(str, periods_fy2))
|
||||
|
||||
period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context)
|
||||
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context)
|
||||
|
@ -147,10 +145,10 @@ def _data_save(self, cr, uid, data, context):
|
|||
'WHERE b.account_id = %s ' \
|
||||
'AND b.reconcile_id is NOT NULL ' \
|
||||
'AND a.reconcile_id = b.reconcile_id ' \
|
||||
'AND b.period_id IN ('+fy_period_set+') ' \
|
||||
'AND a.period_id IN ('+fy2_period_set+') ' \
|
||||
'AND b.period_id =ANY(%s)'\
|
||||
'AND a.period_id =ANY(%s)' \
|
||||
'ORDER BY id ' \
|
||||
'LIMIT %s OFFSET %s', (account.id, limit, offset))
|
||||
'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset))
|
||||
result = cr.dictfetchall()
|
||||
if not result:
|
||||
break
|
||||
|
@ -208,7 +206,6 @@ def _data_save(self, cr, uid, data, context):
|
|||
cr.execute('UPDATE account_fiscalyear ' \
|
||||
'SET end_journal_period_id = %s ' \
|
||||
'WHERE id = %s', (ids[0], old_fyear.id))
|
||||
|
||||
return {}
|
||||
|
||||
class wiz_journal_close(wizard.interface):
|
||||
|
|
|
@ -105,8 +105,8 @@ def _check(self, cr, uid, data, context):
|
|||
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 """%(data['form']['date_from'])
|
||||
cr.execute(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'],))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
|
||||
|
|
|
@ -43,7 +43,7 @@ def _remove_entries(self, cr, uid, data, context):
|
|||
period_journal = data_fyear.end_journal_period_id
|
||||
ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
|
||||
if ids_move:
|
||||
cr.execute('delete from account_move where id in ('+','.join(map(str, ids_move))+')')
|
||||
cr.execute('delete from account_move where id =ANY(%s)',(ids_move,))
|
||||
#cr.execute('UPDATE account_journal_period ' \
|
||||
# 'SET state = %s ' \
|
||||
# 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
|
||||
|
|
|
@ -99,10 +99,9 @@ class wizard_report(wizard.interface):
|
|||
return data['form']
|
||||
|
||||
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 """%(data['form']['date1'])
|
||||
cr.execute(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']['date1'],))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||
|
|
|
@ -80,17 +80,14 @@ class wiz_refund(wizard.interface):
|
|||
#in multi company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop and company_id = %s limit 1 """%(
|
||||
form['date'],
|
||||
pool.get('res.users').browse(cr,uid,uid).company_id.id
|
||||
))
|
||||
between date_start AND date_stop and company_id = %s limit 1 """,
|
||||
(form['date'],pool.get('res.users').browse(cr,uid,uid).company_id.id,))
|
||||
else:
|
||||
#in mono company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop limit 1 """%(
|
||||
form['date'],
|
||||
))
|
||||
between date_start AND date_stop limit 1 """,
|
||||
(form['date'],))
|
||||
res = cr.fetchone()
|
||||
if res:
|
||||
period = res[0]
|
||||
|
|
|
@ -113,8 +113,8 @@ class wizard_report(wizard.interface):
|
|||
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 """%(data['form']['date1'])
|
||||
cr.execute(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']['date1']))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||
|
|
Loading…
Reference in New Issue