diff --git a/addons/account/account.py b/addons/account/account.py
index a03e29e711d..ac14f0d7abe 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -2611,21 +2611,38 @@ class account_low_level_report(osv.osv):
_name = "account.low.level.report"
_description = "Account Report"
- def _get_balance(self, cr, uid, ids, context=None):
- balance = 0.0
+ def _get_children_by_order(self, cr, uid, ids, context=None):
+ res = []
+ for id in ids:
+ res.append(id)
+ ids2 = self.search(cr, uid, [('parent_id', '=', id)], order='sequence ASC', context=context)
+ res += self._get_children_by_order(cr, uid, ids2, context=context)
+ return res
+
+ def _get_balance(self, cr, uid, ids, name, args, context=None):
+ res = {}
+ res_all = {}
for report in self.browse(cr, uid, ids, context=context):
- if report.type == 'accounts':
+ balance = 0.0
+ if report.id in res_all:
+ balance = res_all[report.id]
+ elif report.type == 'accounts':
# it's the sum of balance of the linked accounts
- for a in child.account_ids:
+ for a in report.account_ids:
balance += a.balance
elif report.type == 'account_report' and report.account_report_id:
# it's the amount of the linked report
balance = report.account_report_id.balance
elif report.type == 'sum':
# it's the sum of balance of the children of this account.report
- for child in report.children_ids:
- balance += child.balance
- return balance
+ #for child in report.children_ids:
+ res2 = self._get_balance(cr, uid, [rec.id for rec in report.children_ids], 'balance', False, context=context)
+ res_all.update(res2)
+ for key, value in res2.items():
+ balance += value
+ res[report.id] = balance
+ res_all[report.id] = balance
+ return res
_columns = {
'name': fields.char('Report Name', size=128, required=True),
diff --git a/addons/account/report/account_low_level_report.py b/addons/account/report/account_low_level_report.py
index 18b6386e9f5..10e5efaea7d 100644
--- a/addons/account/report/account_low_level_report.py
+++ b/addons/account/report/account_low_level_report.py
@@ -94,9 +94,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header):
def get_lines(self, data):
lines = []
- import pdb;pdb.set_trace()
- ids2 = self.search(cr, uid, [('parent_id', 'child_of', data['form']['report_id'])], context=self.context)
- for report in self.pool.get('account.low.level.report').browse(self.cr, self.uid, ids2, context=self.context):
+ ids2 = self.pool.get('account.low.level.report')._get_children_by_order(self.cr, self.uid, [data['form']['account_report_id'][0]], context=data['form']['used_context'])
+ for report in self.pool.get('account.low.level.report').browse(self.cr, self.uid, ids2, context=data['form']['used_context']):
vals = {
'name': report.name,
'balance': report.balance,
diff --git a/addons/account/report/account_low_level_report.rml b/addons/account/report/account_low_level_report.rml
index 3d241997417..5b5599adccb 100644
--- a/addons/account/report/account_low_level_report.rml
+++ b/addons/account/report/account_low_level_report.rml
@@ -231,25 +231,19 @@
Accounts
-
+
- |
- Code
- |
Name
|
Balance
|
-
- [[ r['label'] ]]
- |
- [[ repeatIn(get_lines(r['id'], data), 'a') ]]
- | [[a.name]] |
- [[a.balance]] |
+ [[ repeatIn(get_lines(data), 'a') ]]
+ [[a.get('name', '')]] |
+ [[a.get('balance',0.0)]] |