# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
+# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
class account_analytic_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_analytic_balance, self).__init__(cr, uid, name, context)
+ self.done_l = []
self.localcontext.update( {
'time': time,
'lines_g': self._lines_g,
'move_sum_balance': self._move_sum_balance,
'move_sum_quantity': self._move_sum_quantity,
})
-
+
def _lines_g(self, account_id, date1, date2):
+ res = []
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', [account_id])])
- self.cr.execute("SELECT aa.name AS name, aa.code AS code, \
- sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
- 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 \
- ORDER BY aal.code", (date1, date2))
- res = self.cr.dictfetchall()
-
- for r in res:
- if r['balance'] > 0:
- r['debit'] = r['balance']
- r['credit'] = 0.0
- elif r['balance'] < 0:
- r['debit'] = 0.0
- r['credit'] = -r['balance']
+ temp_l = ids
+ for id in ids:
+ if id not in self.done_l:
+ self.done_l.append(id)
else:
- r['balance'] == 0
- r['debit'] = 0.0
- r['credit'] = 0.0
+ temp_l.remove(id)
+ if temp_l:
+ self.cr.execute("SELECT aa.name AS name, aa.code AS code, \
+ sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
+ 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, temp_l)) + "))\
+ AND (date>=%s) AND (date<=%s) AND aa.active \
+ 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']
+ r['credit'] = 0.0
+ elif r['balance'] < 0:
+ r['debit'] = 0.0
+ r['credit'] = -r['balance']
+ else:
+ r['balance'] == 0
+ r['debit'] = 0.0
+ r['credit'] = 0.0
return res
-
+
def _move_sum_debit(self, account_id, date1, date2):
account_analytic_obj = self.pool.get('account.analytic.account')
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_debit(account_id, date1, date2)
+ debit = self._move_sum_debit(account_id, date1, date2)
credit = self._move_sum_credit(account_id, date1, date2)
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,
(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):
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):
<blockTable colWidths="539.0" style="Table_Tilte">
<tr>
<td>
- <para style="terp_header_Centre">Analitic Journal - [[ company.currency_id.name ]]</para>
+ <para style="terp_header_Centre">Analytic Journal - [[ company.currency_id.name ]]</para>
</td>
</tr>
<tr>
</para>
</td>
<td>
- <para style="terp_default_9">[[ move.name ]]</para>
+ <para style="terp_default_9">[[ move.name ]] KI</para>
</td>
<td>
- <para style="terp_default_9">[[ move.account_id.code ]] - [[ move.account_id.name ]]</para>
+ <para style="terp_default_9">[[ move.account_id.code ]] [[ move.account_id.name ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(move.debit-move.credit) ]]</para>
<blockTable colWidths="85.0,62.0,168.0,73.0,74.0,77.0" style="Table4">
<tr>
<td>
- <para style="terp_default_9">[[ move_a or removeParentNode('blockTable') ]] [[ formatLang(move_a.date,date = True) ]]</para>
+ <para style="terp_default_9">[[ (not move_a) and removeParentNode('blockTable') ]] [[ formatLang(move_a.date,date = True) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ move_a.code ]]</para>
</td>
<td>
- <para style="terp_default_9">[[ move_a.name ]]</para>
+ <para style="terp_default_9">[[ move_a.name ]] asgfas</para>
</td>
<td>
<para style="terp_default_9">[[ move_a.account_id.code ]] - [[ move_a.account_id.name ]]</para>
<blockTable colWidths="85.0,62.0,168.0,73.0,74.0,77.0" style="Table3">
<tr>
<td>
- <para style="terp_default_9">[[ move_a or removeParentNode('blockTable') ]] [[ formatLang(move_a.date,date = True) ]]</para>
+ <para style="terp_default_9">[[ (not move_a) and removeParentNode('blockTable') ]] [[ formatLang(move_a.date,date = True) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ move_a.code ]]</para>