Merge lp:~humbertoarocha/account-financial-report/7.0-afr-posted_entries_only-dev-hbto into lp:~account-report-core-editor/account-financial-report/7.0

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Merged
Merged at revision: 43
Proposed branch: lp:~humbertoarocha/account-financial-report/7.0-afr-posted_entries_only-dev-hbto
Merge into: lp:~account-report-core-editor/account-financial-report/7.0
Diff against target: 83 lines (+48/-3)
1 file modified
account_financial_report/report/parser.py (+48/-3)
To merge this branch: bzr merge lp:~humbertoarocha/account-financial-report/7.0-afr-posted_entries_only-dev-hbto
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo Approve
Review via email: mp+177124@code.launchpad.net

Description of the change

Now the Consolidating Accounts are show in a more smart way
when asking the whole chart of account.

To post a comment you must log in.
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Tested in production, everything Ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_financial_report/report/parser.py'
2--- account_financial_report/report/parser.py 2013-07-25 23:47:03 +0000
3+++ account_financial_report/report/parser.py 2013-07-26 10:28:34 +0000
4@@ -440,7 +440,28 @@
5 ('view', 'consolidation'))]))
6
7 account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
8- i[0] for i in all_account_ids]), ('type', 'in', ('view', 'consolidation'))]))
9+ i[0] for i in all_account_ids]),('type', '=', 'view')]))
10+
11+ acc_cons_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
12+ i[0] for i in all_account_ids]), ('type', 'in', ('consolidation',))]))
13+
14+ account_consol_ids = acc_cons_ids and account_obj._get_children_and_consol(
15+ self.cr, self.uid, acc_cons_ids) or []
16+
17+ account_black_ids += account_obj.search(self.cr, self.uid, (
18+ [('id', 'in', account_consol_ids ),
19+ ('type', 'not in',
20+ ('view', 'consolidation'))]))
21+
22+ account_black_ids = list(set(account_black_ids))
23+
24+ c_account_not_black_ids = account_obj.search(self.cr, self.uid, ([
25+ ('id', 'in', account_consol_ids),
26+ ('type', '=', 'view')]))
27+ delete_cons = False
28+ if c_account_not_black_ids:
29+ delete_cons = set(account_not_black_ids) & set(c_account_not_black_ids) and True or False
30+ account_not_black_ids = list(set(account_not_black_ids) - set(c_account_not_black_ids))
31
32 # This could be done quickly with a sql sentence
33 account_not_black = account_obj.browse(
34@@ -449,6 +470,25 @@
35 account_not_black.reverse()
36 account_not_black_ids = [i.id for i in account_not_black]
37
38+ c_account_not_black = account_obj.browse(
39+ self.cr, self.uid, c_account_not_black_ids)
40+ c_account_not_black.sort(key=lambda x: x.level)
41+ c_account_not_black.reverse()
42+ c_account_not_black_ids = [i.id for i in c_account_not_black]
43+
44+ if delete_cons:
45+ account_not_black_ids = c_account_not_black_ids + account_not_black_ids
46+ account_not_black = c_account_not_black + account_not_black
47+ else:
48+ acc_cons_brw = account_obj.browse(
49+ self.cr, self.uid, acc_cons_ids)
50+ acc_cons_brw.sort(key=lambda x: x.level)
51+ acc_cons_brw.reverse()
52+ acc_cons_ids = [i.id for i in acc_cons_brw]
53+
54+ account_not_black_ids = c_account_not_black_ids + acc_cons_ids + account_not_black_ids
55+ account_not_black = c_account_not_black + acc_cons_brw + account_not_black
56+
57 all_account_period = {} # All accounts per period
58
59 # Iteration limit depending on the number of columns
60@@ -514,8 +554,12 @@
61 ) #It makes a copy because they modify
62
63 for acc_id in account_not_black_ids:
64- acc_childs = dict_not_black.get(acc_id).get('obj').child_id
65+ acc_childs = dict_not_black.get(acc_id).get('obj').type=='view' \
66+ and dict_not_black.get(acc_id).get('obj').child_id \
67+ or dict_not_black.get(acc_id).get('obj').child_consol_ids
68 for child_id in acc_childs:
69+ if child_id.type == 'consolidation' and delete_cons:
70+ continue
71 dict_not_black.get(acc_id)['debit'] += all_account.get(
72 child_id.id).get('debit')
73 dict_not_black.get(acc_id)['credit'] += all_account.get(
74@@ -542,7 +586,8 @@
75
76 for aa_id in account_ids:
77 id = aa_id[0]
78-
79+ if aa_id[3].type == 'consolidation' and delete_cons:
80+ continue
81 #
82 # Check if we need to include this level
83 #