[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:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -34,15 +34,14 @@ 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):
|
||||
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)
|
||||
|
@ -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,26 +64,25 @@ 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 = ''
|
||||
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 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())
|
||||
|
||||
|
@ -115,23 +111,23 @@ class account_analytic_account(osv.osv):
|
|||
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:
|
||||
return res
|
||||
|
||||
|
||||
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.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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -47,7 +47,7 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
self.empty_acc = False
|
||||
self.acc_data_dict = {}# maintains a relation with an account with its successors.
|
||||
self.acc_sum_list = []# maintains a list of all ids
|
||||
|
||||
|
||||
def get_children(self, ids):
|
||||
ids2 = []
|
||||
read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids,['child_ids','code','complete_name','balance'])
|
||||
|
@ -56,23 +56,23 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
inculde_empty = True
|
||||
if (not self.empty_acc) and data['balance'] == 0.00:
|
||||
inculde_empty = False
|
||||
if inculde_empty:
|
||||
if inculde_empty:
|
||||
self.acc_ids.append(data['id'])
|
||||
self.read_data.append(data)
|
||||
if data['child_ids']:
|
||||
res = self.get_children(data['child_ids'])
|
||||
return True
|
||||
|
||||
|
||||
res = self.get_children(data['child_ids'])
|
||||
return True
|
||||
|
||||
|
||||
def _get_objects(self, empty_acc):
|
||||
if self.read_data:
|
||||
return self.read_data
|
||||
self.empty_acc = empty_acc
|
||||
self.read_data = []
|
||||
self.get_children(self.ids)
|
||||
|
||||
|
||||
return self.read_data
|
||||
|
||||
|
||||
def _lines_g(self, account_id, date1, date2):
|
||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||
ids = account_analytic_obj.search(self.cr, self.uid,
|
||||
|
@ -86,7 +86,7 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \
|
||||
ORDER BY aal.code", (date1, date2))
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
|
||||
for r in res:
|
||||
if r['balance'] > 0:
|
||||
r['debit'] = r['balance']
|
||||
|
@ -99,7 +99,7 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
r['debit'] = 0.0
|
||||
r['credit'] = 0.0
|
||||
return res
|
||||
|
||||
|
||||
def _move_sum(self, account_id, date1, date2, option):
|
||||
if account_id not in self.acc_data_dict:
|
||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||
|
@ -107,24 +107,23 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
self.acc_data_dict[account_id] = ids
|
||||
else:
|
||||
ids = self.acc_data_dict[account_id]
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
# def _move_sum_debit(self, account_id, date1, date2):
|
||||
# account_analytic_obj = self.pool.get('account.analytic.account')
|
||||
|
@ -147,12 +146,12 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
# AND date>=%s AND date<=%s AND amount<0",
|
||||
# (date1, date2))
|
||||
# return self.cr.fetchone()[0] or 0.0
|
||||
#
|
||||
#
|
||||
def _move_sum_balance(self, account_id, date1, date2):
|
||||
debit = self._move_sum(account_id, date1, date2, 'debit')
|
||||
debit = self._move_sum(account_id, date1, date2, 'debit')
|
||||
credit = self._move_sum(account_id, date1, date2, 'credit')
|
||||
return (debit-credit)
|
||||
|
||||
|
||||
# def _move_sum_quantity(self, account_id, date1, date2):
|
||||
# account_analytic_obj = self.pool.get('account.analytic.account')
|
||||
# ids = account_analytic_obj.search(self.cr, self.uid,
|
||||
|
@ -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,25 +174,21 @@ 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
|
||||
|
||||
|
||||
|
||||
# def _sum_debit(self, accounts, date1, date2):
|
||||
# ids = map(lambda x: x['id'], accounts)
|
||||
# if not len(ids):
|
||||
|
@ -208,7 +202,7 @@ class account_analytic_balance(report_sxw.rml_parse):
|
|||
# AND date>=%s AND date<=%s AND amount>0",
|
||||
# (date1, date2))
|
||||
# return self.cr.fetchone()[0] or 0.0
|
||||
#
|
||||
#
|
||||
# def _sum_credit(self, accounts, date1, date2):
|
||||
# ids = map(lambda x: x['id'], accounts)
|
||||
# if not len(ids):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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) \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -85,7 +85,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse):
|
|||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
def _account_sum_balance(self, account_id, date1, date2):
|
||||
debit = self._account_sum_debit(account_id, date1, date2)
|
||||
debit = self._account_sum_debit(account_id, date1, date2)
|
||||
credit = self._account_sum_credit(account_id, date1, date2)
|
||||
return (debit-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):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -57,10 +57,10 @@ 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)
|
||||
len_res = len(res)
|
||||
for r in res:
|
||||
if (r == res[len_res-1]):
|
||||
result+=r[0]+". "
|
||||
|
@ -75,10 +75,10 @@ class account_balance(report_sxw.rml_parse):
|
|||
result+=r.name+". "
|
||||
else:
|
||||
result+=r.name+", "
|
||||
|
||||
|
||||
return str(result and result[:-1]) or ''
|
||||
|
||||
|
||||
|
||||
def lines(self, form, ids={}, done=None, level=1):
|
||||
if not ids:
|
||||
ids = self.ids
|
||||
|
@ -98,7 +98,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
ctx['periods'] = form['periods'][0][2]
|
||||
elif form['state']== 'bydate':
|
||||
ctx['date_from'] = form['date_from']
|
||||
ctx['date_to'] = form['date_to']
|
||||
ctx['date_to'] = form['date_to']
|
||||
elif form['state'] == 'all' :
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['date_from'] = form['date_from']
|
||||
|
@ -165,7 +165,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
#
|
||||
# result_acc += self.lines(form, ids2, done, level+1)
|
||||
return result_acc
|
||||
|
||||
|
||||
def _sum_credit(self):
|
||||
return self.sum_credit
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -47,26 +47,26 @@ 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 = []
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
self.line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': form['fiscalyear']})
|
||||
self.cr.execute("""SELECT DISTINCT res_partner.id AS id,
|
||||
res_partner.name AS name
|
||||
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' )))
|
||||
AND (line.partner_id=res_partner.id)
|
||||
AND (account_account.company_id = %s)
|
||||
ORDER BY res_partner.name""" % (form['date1'],form['company_id']))
|
||||
self.cr.execute("""SELECT DISTINCT res_partner.id AS id,
|
||||
res_partner.name AS name
|
||||
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 )))
|
||||
AND (line.partner_id=res_partner.id)
|
||||
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
|
||||
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)
|
||||
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)
|
||||
WHERE (line.account_id = account_account.id)
|
||||
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' )))
|
||||
AND (account_account.company_id = %s)
|
||||
AND account_account.active
|
||||
GROUP BY partner_id""" % (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id']))
|
||||
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'],))
|
||||
t = self.cr.fetchall()
|
||||
for i in t:
|
||||
totals[i[0]] = i[1]
|
||||
|
@ -95,17 +95,17 @@ class aged_trial_report(rml_parse.rml_parse):
|
|||
# This dictionary will store the future or past of all partners
|
||||
future_past = {}
|
||||
if form['direction_selection'] == 'future':
|
||||
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)
|
||||
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 =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' )))
|
||||
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']))
|
||||
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'],))
|
||||
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 = {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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]
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -41,25 +41,25 @@ class tax_report(rml_parse.rml_parse):
|
|||
'get_lines' : self._get_lines,
|
||||
})
|
||||
|
||||
|
||||
|
||||
def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0):
|
||||
res = self._get_codes(based_on,company_id,parent,level,period_list)
|
||||
|
||||
|
||||
if period_list[0][2] :
|
||||
res = self._add_codes(based_on,res,period_list)
|
||||
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])
|
||||
res = self._add_codes(based_on,res,period_list)
|
||||
|
||||
|
||||
i = 0
|
||||
top_result = []
|
||||
while i < len(res):
|
||||
|
||||
|
||||
res_dict = { 'code' : res[i][1].code,
|
||||
'name' : res[i][1].name,
|
||||
'debit' : 0,
|
||||
|
@ -69,7 +69,7 @@ class tax_report(rml_parse.rml_parse):
|
|||
'level' : res[i][0],
|
||||
'pos' : 0
|
||||
}
|
||||
|
||||
|
||||
top_result.append(res_dict)
|
||||
res_general = self._get_general(res[i][1].id,period_list,company_id,based_on)
|
||||
ind_general = 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,14 +127,14 @@ 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 +') \
|
||||
|
||||
|
||||
i = 0
|
||||
while i<len(res):
|
||||
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
|
||||
|
@ -145,14 +144,14 @@ class tax_report(rml_parse.rml_parse):
|
|||
def _get_codes(self,based_on, company_id, parent=False, level=0,period_list=[]):
|
||||
tc = self.pool.get('account.tax.code')
|
||||
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)])
|
||||
|
||||
|
||||
res = []
|
||||
for code in tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
|
||||
res.append(('.'*2*level,code))
|
||||
|
||||
|
||||
res += self._get_codes(based_on, company_id, code.id, level+1)
|
||||
return res
|
||||
|
||||
|
||||
def _add_codes(self,based_on, account_list=[],period_list=[]):
|
||||
res = []
|
||||
for account in account_list:
|
||||
|
@ -162,19 +161,19 @@ class tax_report(rml_parse.rml_parse):
|
|||
for period_ind in period_list[0][2]:
|
||||
for code in tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
|
||||
sum_tax_add = sum_tax_add + code.sum_period
|
||||
|
||||
|
||||
code.sum_period = sum_tax_add
|
||||
|
||||
|
||||
res.append((account[0],code))
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def _get_company(self, form):
|
||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
||||
|
||||
def _get_currency(self, form):
|
||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
||||
|
||||
|
||||
def sort_result(self,accounts):
|
||||
# On boucle sur notre rapport
|
||||
result_accounts = []
|
||||
|
@ -184,13 +183,13 @@ class tax_report(rml_parse.rml_parse):
|
|||
#
|
||||
account_elem = accounts[ind]
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# we will now check if the level is lower than the previous level, in this case we will make a subtotal
|
||||
if (account_elem['level'] < old_level):
|
||||
bcl_current_level = old_level
|
||||
bcl_rup_ind = ind - 1
|
||||
|
||||
|
||||
while (bcl_current_level >= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ):
|
||||
tot_elem = copy.copy(accounts[bcl_rup_ind])
|
||||
res_tot = { 'code' : accounts[bcl_rup_ind]['code'],
|
||||
|
@ -202,21 +201,21 @@ class tax_report(rml_parse.rml_parse):
|
|||
'level' : 0,
|
||||
'pos' : 0
|
||||
}
|
||||
|
||||
|
||||
if res_tot['type'] == 1:
|
||||
# on change le type pour afficher le total
|
||||
res_tot['type'] = 2
|
||||
result_accounts.append(res_tot)
|
||||
bcl_current_level = accounts[bcl_rup_ind]['level']
|
||||
bcl_rup_ind -= 1
|
||||
|
||||
|
||||
old_level = account_elem['level']
|
||||
result_accounts.append(account_elem)
|
||||
ind+=1
|
||||
|
||||
|
||||
|
||||
|
||||
return result_accounts
|
||||
|
||||
|
||||
|
||||
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
|
||||
'addons/account/report/tax_report.rml', parser=tax_report, header=False)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -102,7 +102,7 @@ class wizard_report(wizard.interface):
|
|||
# else :
|
||||
# data['form']['fiscalyear'] = 1
|
||||
return data['form']
|
||||
|
||||
|
||||
def _check_path(self, cr, uid, data, context):
|
||||
if data['model'] == 'account.account':
|
||||
return 'checktype'
|
||||
|
@ -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']):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -56,14 +56,12 @@ 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)
|
||||
old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context)
|
||||
|
||||
|
||||
new_journal = data['form']['journal_id']
|
||||
new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context)
|
||||
|
||||
|
@ -87,7 +85,7 @@ def _data_save(self, cr, uid, data, context):
|
|||
ids = map(lambda x: x[0], cr.fetchall())
|
||||
for account in pool.get('account.account').browse(cr, uid, ids,
|
||||
context={'fiscalyear': fy_id}):
|
||||
|
||||
|
||||
accnt_type_data = account.user_type
|
||||
if not accnt_type_data:
|
||||
continue
|
||||
|
@ -133,7 +131,7 @@ def _data_save(self, cr, uid, data, context):
|
|||
})
|
||||
offset += limit
|
||||
|
||||
#We have also to consider all move_lines that were reconciled
|
||||
#We have also to consider all move_lines that were reconciled
|
||||
#on another fiscal year, and report them too
|
||||
offset = 0
|
||||
limit = 100
|
||||
|
@ -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
|
||||
|
@ -178,7 +176,7 @@ def _data_save(self, cr, uid, data, context):
|
|||
'AND ' + query_line + ' ' \
|
||||
'ORDER BY id ' \
|
||||
'LIMIT %s OFFSET %s', (account.id, 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):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -46,7 +46,7 @@ period_form = '''<?xml version="1.0"?>
|
|||
<field name="sortbydate" required="True"/>
|
||||
|
||||
<field name="soldeinit" invisible="1"/>
|
||||
|
||||
|
||||
<field name="landscape"/>
|
||||
<field name="amount_currency"/>
|
||||
<newline/>
|
||||
|
@ -65,10 +65,10 @@ period_form = '''<?xml version="1.0"?>
|
|||
</group>
|
||||
</group>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</form>'''
|
||||
|
||||
period_fields = {
|
||||
|
@ -103,10 +103,10 @@ def _check(self, cr, uid, data, context):
|
|||
return 'report'
|
||||
|
||||
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']):
|
||||
|
@ -116,14 +116,14 @@ def _check_date(self, cr, uid, data, context):
|
|||
|
||||
else:
|
||||
raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
|
||||
|
||||
|
||||
def _check_state(self, cr, uid, data, context):
|
||||
|
||||
if data['form']['state'] == 'bydate':
|
||||
_check_date(self, cr, uid, data, context)
|
||||
# data['form']['fiscalyear'] = 0
|
||||
# else :
|
||||
#
|
||||
#
|
||||
# data['form']['fiscalyear'] = 1
|
||||
return data['form']
|
||||
|
||||
|
@ -137,7 +137,7 @@ class wizard_report(wizard.interface):
|
|||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
|
||||
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
#periods_obj=pooler.get_pool(cr.dbname).get('account.period')
|
||||
#data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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)',
|
||||
|
@ -60,17 +60,17 @@ class open_closed_fiscal(wizard.interface):
|
|||
'init' : {
|
||||
'actions' : [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'type': 'form',
|
||||
'arch': form,
|
||||
'fields': fields,
|
||||
'fields': fields,
|
||||
'state':[('end','Cancel'),('open','Open')]
|
||||
}
|
||||
},
|
||||
'open': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type':'action',
|
||||
'action':_remove_entries,
|
||||
'type':'action',
|
||||
'action':_remove_entries,
|
||||
'state':'end'
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -74,14 +74,14 @@ period_fields = {
|
|||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
||||
|
||||
def _get_defaults(self,cr,uid,data,context):
|
||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
company_id = user.company_id.id
|
||||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
|
@ -91,25 +91,24 @@ class wizard_report(wizard.interface):
|
|||
data['form']['fiscalyear'] = False
|
||||
data['form']['result_selection'] = 'all'
|
||||
return data['form']
|
||||
|
||||
|
||||
def _check_state(self, cr, uid, data, context):
|
||||
|
||||
|
||||
if data['form']['state'] == 'bydate' :
|
||||
self._check_date(cr, uid, data, context)
|
||||
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']):
|
||||
raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop'])))
|
||||
else:
|
||||
return 'report'
|
||||
|
||||
|
||||
else:
|
||||
raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
|
||||
|
||||
|
@ -118,7 +117,7 @@ class wizard_report(wizard.interface):
|
|||
'actions': [_get_defaults],
|
||||
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
|
||||
},
|
||||
|
||||
|
||||
'report': {
|
||||
'actions': [_check_state],
|
||||
'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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]
|
||||
|
@ -101,10 +98,10 @@ class wiz_refund(wizard.interface):
|
|||
description = form['description']
|
||||
else:
|
||||
description = inv.name
|
||||
|
||||
|
||||
if not period:
|
||||
raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
|
||||
|
||||
|
||||
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
|
||||
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
|
||||
# we compute due date
|
||||
|
@ -112,7 +109,7 @@ class wiz_refund(wizard.interface):
|
|||
pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total})
|
||||
# to make the taxes calculated
|
||||
pool.get('account.invoice').button_compute(cr, uid, refund_id)
|
||||
|
||||
|
||||
created_inv.append(refund_id[0])
|
||||
#if inv is paid we unreconcile
|
||||
if mode in ('cancel','modify'):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -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