Merge lp:~unifield-team/unifield-server/us-1197 into lp:unifield-server
- us-1197
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3710 |
Proposed branch: | lp:~unifield-team/unifield-server/us-1197 |
Merge into: | lp:unifield-server |
Diff against target: |
380 lines (+124/-72) 5 files modified
bin/addons/account/report/account_general_ledger.py (+34/-6) bin/addons/account/report/account_general_ledger_landscape.rml (+11/-5) bin/addons/account/report/account_general_ledger_xls.mako (+27/-21) bin/addons/account/wizard/account_report_general_ledger.py (+1/-3) bin/addons/finance/account_drill.py (+51/-37) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-1197 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+291888@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/addons/account/report/account_general_ledger.py' | |||
2 | --- bin/addons/account/report/account_general_ledger.py 2016-04-06 14:00:48 +0000 | |||
3 | +++ bin/addons/account/report/account_general_ledger.py 2016-04-14 13:25:24 +0000 | |||
4 | @@ -66,6 +66,18 @@ | |||
5 | 66 | 'show_period_0': 1, | 66 | 'show_period_0': 1, |
6 | 67 | 'state_agnostic': 1, | 67 | 'state_agnostic': 1, |
7 | 68 | }) | 68 | }) |
8 | 69 | # US-1197/4: IB entries for yearly closing always in 1th Jan | ||
9 | 70 | # => get rid of regular period/dates filters for _query_get | ||
10 | 71 | # => if self.init_balance is True, note that filtering is OK | ||
11 | 72 | # validated at wizard report level | ||
12 | 73 | ib_local_context.update({ | ||
13 | 74 | 'date_from': False, | ||
14 | 75 | 'date_to': False, | ||
15 | 76 | 'date_fromto_docdate': False, | ||
16 | 77 | 'period_from': False, | ||
17 | 78 | 'period_to': False, | ||
18 | 79 | 'periods': False, | ||
19 | 80 | }) | ||
20 | 69 | self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', | 81 | self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', |
21 | 70 | context=ib_local_context) | 82 | context=ib_local_context) |
22 | 71 | else: | 83 | else: |
23 | @@ -226,12 +238,18 @@ | |||
24 | 226 | 238 | ||
25 | 227 | def _show_node_in_report(self, node): | 239 | def _show_node_in_report(self, node): |
26 | 228 | res = True | 240 | res = True |
33 | 229 | if self.account_ids or self.unreconciled_filter: | 241 | if node.parent is None: |
34 | 230 | # hide if zero bal and any by account or unreconciled filter on | 242 | return res # always show root account MSF |
35 | 231 | bal = node.data.get('*', {}).get('debit', 0.) \ | 243 | if self.account_ids or self.account_report_types \ |
36 | 232 | - node.data.get('*', {}).get('credit', 0.) | 244 | or self.unreconciled_filter: |
37 | 233 | if bal == 0.: | 245 | res = not node.skip |
38 | 234 | res = False | 246 | if res: |
39 | 247 | # hide if zero bal and any by account or unreconciled filter on | ||
40 | 248 | bal = node.data.get('*', {}).get('debit', 0.) \ | ||
41 | 249 | - node.data.get('*', {}).get('credit', 0.) | ||
42 | 250 | if bal == 0.: | ||
43 | 251 | res = False | ||
44 | 252 | |||
45 | 235 | return res | 253 | return res |
46 | 236 | 254 | ||
47 | 237 | def _get_journals_str(self, data): | 255 | def _get_journals_str(self, data): |
48 | @@ -393,6 +411,7 @@ | |||
49 | 393 | line = self.get_start_period(data) + ' - ' + self.get_end_period(data) | 411 | line = self.get_start_period(data) + ' - ' + self.get_end_period(data) |
50 | 394 | if line: | 412 | if line: |
51 | 395 | infos.append(line) | 413 | infos.append(line) |
52 | 414 | |||
53 | 396 | return infos and ", \n".join(infos) or _('No Filter') | 415 | return infos and ", \n".join(infos) or _('No Filter') |
54 | 397 | 416 | ||
55 | 398 | def _get_line_debit(self, line, booking=False): | 417 | def _get_line_debit(self, line, booking=False): |
56 | @@ -479,6 +498,15 @@ | |||
57 | 479 | display_account = _('With balance is not equal to 0') | 498 | display_account = _('With balance is not equal to 0') |
58 | 480 | info_data.append((_('Accounts'), display_account, )) | 499 | info_data.append((_('Accounts'), display_account, )) |
59 | 481 | 500 | ||
60 | 501 | account_ids = list(set(self._get_data_form(data, 'account_ids'))) | ||
61 | 502 | if account_ids: | ||
62 | 503 | # US-1197/2: display filtered accounts | ||
63 | 504 | account_obj = self.pool.get('account.account') | ||
64 | 505 | info_data.append((_('Selected Accounts'), ', '.join( | ||
65 | 506 | [ a.code for a in account_obj.browse( | ||
66 | 507 | self.cr, self.uid, account_ids) \ | ||
67 | 508 | if a.type != 'view' ], ))) | ||
68 | 509 | |||
69 | 482 | res = [ "%s: %s" % (label, val, ) for label, val in info_data ] | 510 | res = [ "%s: %s" % (label, val, ) for label, val in info_data ] |
70 | 483 | return ', \n'.join(res) | 511 | return ', \n'.join(res) |
71 | 484 | 512 | ||
72 | 485 | 513 | ||
73 | === modified file 'bin/addons/account/report/account_general_ledger_landscape.rml' | |||
74 | --- bin/addons/account/report/account_general_ledger_landscape.rml 2016-03-31 09:45:40 +0000 | |||
75 | +++ bin/addons/account/report/account_general_ledger_landscape.rml 2016-04-14 13:25:24 +0000 | |||
76 | @@ -248,7 +248,7 @@ | |||
77 | 248 | [[ get_show_move_lines() or removeParentNode('blockTable') ]] | 248 | [[ get_show_move_lines() or removeParentNode('blockTable') ]] |
78 | 249 | <tr> | 249 | <tr> |
79 | 250 | <td> | 250 | <td> |
81 | 251 | <para style="terp_tblheader_Details">Entry Seq</para> | 251 | <para style="terp_tblheader_Details">Account/Entry Seq</para> |
82 | 252 | </td> | 252 | </td> |
83 | 253 | <td> | 253 | <td> |
84 | 254 | <para style="terp_tblheader_Details">Posting Date</para> | 254 | <para style="terp_tblheader_Details">Posting Date</para> |
85 | @@ -330,14 +330,17 @@ | |||
86 | 330 | 330 | ||
87 | 331 | <section> | 331 | <section> |
88 | 332 | <para style="terp_default_8">[[ repeatIn(lines(o, initial_balance_mode=True), 'line') ]]</para> | 332 | <para style="terp_default_8">[[ repeatIn(lines(o, initial_balance_mode=True), 'line') ]]</para> |
90 | 333 | <blockTable colWidths="286.0,60.0,110.0,110.0,110.0,110.0" style="Table9"> | 333 | <blockTable colWidths="40.0,246.0,60.0,110.0,110.0,110.0,110.0" style="Table9"> |
91 | 334 | [[ show_node_in_report(o) or removeParentNode('blockTable') ]] | 334 | [[ show_node_in_report(o) or removeParentNode('blockTable') ]] |
92 | 335 | <tr> | 335 | <tr> |
93 | 336 | <td> | 336 | <td> |
94 | 337 | <para style="terp_default_9_Right">[[ o.code or '' ]]</para> | ||
95 | 338 | </td> | ||
96 | 339 | <td> | ||
97 | 337 | <para style="terp_default_9_Right">[[ line['move'] or '' ]]</para> | 340 | <para style="terp_default_9_Right">[[ line['move'] or '' ]]</para> |
98 | 338 | </td> | 341 | </td> |
99 | 339 | <td> | 342 | <td> |
101 | 340 | <para style="terp_def114.0,80.0,92.0,60.0,110.0,110.0,110.0,110.0ault_9_Right">[[ line['currency_name'] or '' ]]</para> | 343 | <para style="terp_default_9_Right">[[ line['currency_name'] or '' ]]</para> |
102 | 341 | </td> | 344 | </td> |
103 | 342 | <td> | 345 | <td> |
104 | 343 | <para style="terp_default_9_Right">[[ formatLang(get_line_debit(line, booking=True), digits=get_digits(dp='Account')) ]]</para> | 346 | <para style="terp_default_9_Right">[[ formatLang(get_line_debit(line, booking=True), digits=get_digits(dp='Account')) ]]</para> |
105 | @@ -390,11 +393,14 @@ | |||
106 | 390 | 393 | ||
107 | 391 | <section> | 394 | <section> |
108 | 392 | <para style="terp_default_8">[[ repeatIn(o.get_currencies(), 'ccy') ]]</para> | 395 | <para style="terp_default_8">[[ repeatIn(o.get_currencies(), 'ccy') ]]</para> |
110 | 393 | <blockTable colWidths="286.0,60.0,110.0,110.0,110.0,110.0" style="Table8_subtotal_ccy"> | 396 | <blockTable colWidths="40.0,246.0,60.0,110.0,110.0,110.0,110.0" style="Table8_subtotal_ccy"> |
111 | 394 | [[ show_node_in_report(o) or removeParentNode('blockTable') ]] | 397 | [[ show_node_in_report(o) or removeParentNode('blockTable') ]] |
112 | 395 | <tr> | 398 | <tr> |
113 | 396 | <td> | 399 | <td> |
115 | 397 | <para style="terp_default_9_Right">[[ o.code ]]</para> | 400 | <para style="terp_default_9_Right">[[ o.code or '' ]]</para> |
116 | 401 | </td> | ||
117 | 402 | <td> | ||
118 | 403 | <para style="terp_default_9_Right">Sub Total</para> | ||
119 | 398 | </td> | 404 | </td> |
120 | 399 | <td> | 405 | <td> |
121 | 400 | <para style="terp_default_9_Right">[[ ccy ]]</para> | 406 | <para style="terp_default_9_Right">[[ ccy ]]</para> |
122 | 401 | 407 | ||
123 | === modified file 'bin/addons/account/report/account_general_ledger_xls.mako' | |||
124 | --- bin/addons/account/report/account_general_ledger_xls.mako 2016-03-23 14:52:23 +0000 | |||
125 | +++ bin/addons/account/report/account_general_ledger_xls.mako 2016-04-14 13:25:24 +0000 | |||
126 | @@ -187,21 +187,15 @@ | |||
127 | 187 | display_account = (data['form']['display_account']=='bal_all' and 'All') or (data['form']['display_account']=='bal_movement' and 'With movements') or 'With balance is not equal to 0' | 187 | display_account = (data['form']['display_account']=='bal_all' and 'All') or (data['form']['display_account']=='bal_movement' and 'With movements') or 'With balance is not equal to 0' |
128 | 188 | %> | 188 | %> |
129 | 189 | <Table x:FullColumns="1" x:FullRows="1"> | 189 | <Table x:FullColumns="1" x:FullRows="1"> |
145 | 190 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | 190 | <Column ss:AutoFitWidth="1" ss:Width="50" /> |
146 | 191 | <Column ss:AutoFitWidth="1" ss:Width="120" /> | 191 | <Column ss:AutoFitWidth="1" ss:Width="80" /> |
147 | 192 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | 192 | <Column ss:AutoFitWidth="1" ss:Width="55" /> |
148 | 193 | % if get_show_move_lines(): | 193 | <Column ss:AutoFitWidth="1" ss:Width="80" /> |
149 | 194 | <Column ss:AutoFitWidth="1" ss:Width="300" /> | 194 | <Column ss:AutoFitWidth="1" ss:Width="50" /> |
150 | 195 | % endif | 195 | <Column ss:Width="90" /> |
151 | 196 | % if not get_show_move_lines(): | 196 | <Column ss:Width="90" /> |
152 | 197 | <Column ss:AutoFitWidth="1" ss:Width="150" /> | 197 | <Column ss:Width="90" /> |
153 | 198 | % endif | 198 | <Column ss:Width="90" /> |
139 | 199 | <Column ss:AutoFitWidth="1" ss:Width="50" /> | ||
140 | 200 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | ||
141 | 201 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | ||
142 | 202 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | ||
143 | 203 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | ||
144 | 204 | <Column ss:AutoFitWidth="1" ss:Width="64" /> | ||
154 | 205 | <Row> | 199 | <Row> |
155 | 206 | <Cell ss:StyleID="ssH"><Data ss:Type="String">${header_company_or_chart_of_account}</Data></Cell> | 200 | <Cell ss:StyleID="ssH"><Data ss:Type="String">${header_company_or_chart_of_account}</Data></Cell> |
156 | 207 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Fiscal Year</Data></Cell> | 201 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Fiscal Year</Data></Cell> |
157 | @@ -246,13 +240,14 @@ | |||
158 | 246 | </Row> | 240 | </Row> |
159 | 247 | <Row> | 241 | <Row> |
160 | 248 | % if get_show_move_lines(): | 242 | % if get_show_move_lines(): |
162 | 249 | <Cell ss:StyleID="ssH" ss:MergeAcross="1"><Data ss:Type="String">Entry Seq</Data></Cell> | 243 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Account</Data></Cell> |
163 | 244 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Entry Seq</Data></Cell> | ||
164 | 250 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Posting Date</Data></Cell> | 245 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Posting Date</Data></Cell> |
165 | 251 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Description</Data></Cell> | 246 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Description</Data></Cell> |
166 | 252 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell> | 247 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell> |
167 | 253 | % endif | 248 | % endif |
168 | 254 | % if not get_show_move_lines(): | 249 | % if not get_show_move_lines(): |
170 | 255 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Account / CCY</Data></Cell> | 250 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Account</Data></Cell> |
171 | 256 | <Cell ss:StyleID="ssH" ss:MergeAcross="2"><Data ss:Type="String"></Data></Cell> | 251 | <Cell ss:StyleID="ssH" ss:MergeAcross="2"><Data ss:Type="String"></Data></Cell> |
172 | 257 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell> | 252 | <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell> |
173 | 258 | % endif | 253 | % endif |
174 | @@ -301,7 +296,10 @@ | |||
175 | 301 | 296 | ||
176 | 302 | % for line in lines(o, initial_balance_mode=True): | 297 | % for line in lines(o, initial_balance_mode=True): |
177 | 303 | <Row> | 298 | <Row> |
179 | 304 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="3"> | 299 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}"> |
180 | 300 | <Data ss:Type="String">${(o.code or '')|x}</Data> | ||
181 | 301 | </Cell> | ||
182 | 302 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="2"> | ||
183 | 305 | <Data ss:Type="String">${(line['move'] or '' or '')|x}</Data> | 303 | <Data ss:Type="String">${(line['move'] or '' or '')|x}</Data> |
184 | 306 | </Cell> | 304 | </Cell> |
185 | 307 | <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}"> | 305 | <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}"> |
186 | @@ -333,7 +331,7 @@ | |||
187 | 333 | <Cell ss:StyleID="ssAccountLine"> | 331 | <Cell ss:StyleID="ssAccountLine"> |
188 | 334 | <Data ss:Type="String">${(formatLang(line['ldate'],date=True)) or ''}</Data> | 332 | <Data ss:Type="String">${(formatLang(line['ldate'],date=True)) or ''}</Data> |
189 | 335 | </Cell> | 333 | </Cell> |
191 | 336 | <Cell ss:StyleID="ssAccountLineNoWrap"> | 334 | <Cell ss:StyleID="ssAccountLine"> |
192 | 337 | <Data ss:Type="String">${(line['lname'] or '')|x}</Data> | 335 | <Data ss:Type="String">${(line['lname'] or '')|x}</Data> |
193 | 338 | </Cell> | 336 | </Cell> |
194 | 339 | <Cell ss:StyleID="ssAccountLine"> | 337 | <Cell ss:StyleID="ssAccountLine"> |
195 | @@ -356,9 +354,12 @@ | |||
196 | 356 | 354 | ||
197 | 357 | % for ccy in o.get_currencies(): | 355 | % for ccy in o.get_currencies(): |
198 | 358 | <Row> | 356 | <Row> |
200 | 359 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="3"> | 357 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}"> |
201 | 360 | <Data ss:Type="String">${(o.code or '')|x}</Data> | 358 | <Data ss:Type="String">${(o.code or '')|x}</Data> |
202 | 361 | </Cell> | 359 | </Cell> |
203 | 360 | <Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="2"> | ||
204 | 361 | <Data ss:Type="String">Sub Total</Data> | ||
205 | 362 | </Cell> | ||
206 | 362 | <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}"> | 363 | <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}"> |
207 | 363 | <Data ss:Type="String">${(ccy or '')|x}</Data> | 364 | <Data ss:Type="String">${(ccy or '')|x}</Data> |
208 | 364 | </Cell> | 365 | </Cell> |
209 | @@ -383,7 +384,12 @@ | |||
210 | 383 | <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> | 384 | <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> |
211 | 384 | <PageSetup> | 385 | <PageSetup> |
212 | 385 | <Layout x:Orientation="Landscape"/> | 386 | <Layout x:Orientation="Landscape"/> |
214 | 386 | <Header x:Data="&C&"Arial,Bold"&14General Ledger"/> | 387 | % if get_show_move_lines(): |
215 | 388 | <Header x:Data="&C&"Arial,Bold"&14General Ledger"/>0 | ||
216 | 389 | % endif | ||
217 | 390 | % if not get_show_move_lines(): | ||
218 | 391 | <Header x:Data="&C&"Arial,Bold"&14Trial Balance"/>0 | ||
219 | 392 | % endif | ||
220 | 387 | <Footer x:Data="Page &P of &N"/> | 393 | <Footer x:Data="Page &P of &N"/> |
221 | 388 | </PageSetup> | 394 | </PageSetup> |
222 | 389 | <Print> | 395 | <Print> |
223 | 390 | 396 | ||
224 | === modified file 'bin/addons/account/wizard/account_report_general_ledger.py' | |||
225 | --- bin/addons/account/wizard/account_report_general_ledger.py 2016-03-23 14:52:23 +0000 | |||
226 | +++ bin/addons/account/wizard/account_report_general_ledger.py 2016-04-14 13:25:24 +0000 | |||
227 | @@ -128,9 +128,7 @@ | |||
228 | 128 | fy_rec = self.pool.get('account.fiscalyear').browse(cr, uid, | 128 | fy_rec = self.pool.get('account.fiscalyear').browse(cr, uid, |
229 | 129 | fiscalyear_id, context=context) | 129 | fiscalyear_id, context=context) |
230 | 130 | if filter in ('filter_date_doc', 'filter_date', ): | 130 | if filter in ('filter_date_doc', 'filter_date', ): |
234 | 131 | ib_available = date_from and date_to \ | 131 | ib_available = date_from and date_from == fy_rec.date_start |
232 | 132 | and date_from == fy_rec.date_start \ | ||
233 | 133 | and date_to <= fy_rec.date_stop | ||
235 | 134 | elif filter in 'filter_period': | 132 | elif filter in 'filter_period': |
236 | 135 | if not period_from or not period_to: | 133 | if not period_from or not period_to: |
237 | 136 | ib_available = False | 134 | ib_available = False |
238 | 137 | 135 | ||
239 | === modified file 'bin/addons/finance/account_drill.py' | |||
240 | --- bin/addons/finance/account_drill.py 2016-03-17 08:07:51 +0000 | |||
241 | +++ bin/addons/finance/account_drill.py 2016-04-14 13:25:24 +0000 | |||
242 | @@ -41,6 +41,7 @@ | |||
243 | 41 | # set during map/reduce | 41 | # set during map/reduce |
244 | 42 | self.data = {} | 42 | self.data = {} |
245 | 43 | self.zero_bal = False | 43 | self.zero_bal = False |
246 | 44 | self.skip = False | ||
247 | 44 | 45 | ||
248 | 45 | # set during next_node() calls | 46 | # set during next_node() calls |
249 | 46 | self.code = '' | 47 | self.code = '' |
250 | @@ -80,12 +81,11 @@ | |||
251 | 80 | JOIN res_currency c ON (c.id = l.currency_id) | 81 | JOIN res_currency c ON (c.id = l.currency_id) |
252 | 81 | JOIN account_journal j on (l.journal_id=j.id) | 82 | JOIN account_journal j on (l.journal_id=j.id) |
253 | 82 | JOIN account_account a on (a.id=l.account_id) | 83 | JOIN account_account a on (a.id=l.account_id) |
256 | 83 | JOIN account_account_type at on (at.id=a.user_type) | 84 | WHERE l.account_id = %s{reconcile}{query} |
255 | 84 | WHERE l.account_id = %s{reconcile}{options}{query} | ||
257 | 85 | GROUP BY l.currency_id''' | 85 | GROUP BY l.currency_id''' |
258 | 86 | 86 | ||
259 | 87 | # initial balance move lines base query (from IB journal period 0) | 87 | # initial balance move lines base query (from IB journal period 0) |
261 | 88 | _sql_ib = '''SELECT sum(debit), sum(credit), | 88 | _sql_ib = '''SELECT sum(debit), sum(credit), |
262 | 89 | sum(debit_currency), sum(credit_currency), | 89 | sum(debit_currency), sum(credit_currency), |
263 | 90 | max(c.name) | 90 | max(c.name) |
264 | 91 | FROM account_move_line l | 91 | FROM account_move_line l |
265 | @@ -112,8 +112,28 @@ | |||
266 | 112 | self.query_ib = query_ib or '' | 112 | self.query_ib = query_ib or '' |
267 | 113 | self.move_states = move_states or [ 'draft', 'posted', ] | 113 | self.move_states = move_states or [ 'draft', 'posted', ] |
268 | 114 | self.include_accounts = include_accounts | 114 | self.include_accounts = include_accounts |
269 | 115 | self.account_report_types = account_report_types | ||
270 | 115 | self.with_balance_only = with_balance_only | 116 | self.with_balance_only = with_balance_only |
271 | 116 | self.reconcile_filter = reconcile_filter | 117 | self.reconcile_filter = reconcile_filter |
272 | 118 | if self.account_report_types and not self.include_accounts: | ||
273 | 119 | # deduce included accounts from report type filter | ||
274 | 120 | domain = [ | ||
275 | 121 | ('report_type', 'in' , self.account_report_types), | ||
276 | 122 | ] | ||
277 | 123 | if 'asset' in self.account_report_types \ | ||
278 | 124 | or 'liability' in self.account_report_types: | ||
279 | 125 | # US-227 include tax account for BS accounts selection | ||
280 | 126 | domain = [ '|', ('code', '=', 'tax') ] + domain | ||
281 | 127 | account_types_ids = self.pool.get('account.account.type').search( | ||
282 | 128 | self.cr, self.uid, domain, context=self.context) | ||
283 | 129 | |||
284 | 130 | if account_types_ids: | ||
285 | 131 | domain = [ | ||
286 | 132 | ('type', '!=', 'view'), | ||
287 | 133 | ('user_type', 'in' , account_types_ids), | ||
288 | 134 | ] | ||
289 | 135 | self.include_accounts = self.pool.get('account.account').search( | ||
290 | 136 | self.cr, self.uid, domain, context=self.context) or [] | ||
291 | 117 | 137 | ||
292 | 118 | # nodes | 138 | # nodes |
293 | 119 | self.root = None | 139 | self.root = None |
294 | @@ -125,18 +145,6 @@ | |||
295 | 125 | # JI base query: constructed via _sql | 145 | # JI base query: constructed via _sql |
296 | 126 | self.sql = self._sql | 146 | self.sql = self._sql |
297 | 127 | self.sql = self.sql.replace('{reconcile}', self.reconcile_filter) | 147 | self.sql = self.sql.replace('{reconcile}', self.reconcile_filter) |
298 | 128 | if account_report_types: | ||
299 | 129 | report_types = [ "'%s'" % (rt, ) for rt in account_report_types ] | ||
300 | 130 | options = " AND (at.report_type in (%s)" % ( | ||
301 | 131 | ','.join(report_types), ) | ||
302 | 132 | if 'asset' in account_report_types \ | ||
303 | 133 | or 'liability' in account_report_types: | ||
304 | 134 | # US-227 include tax account for BS accounts selection | ||
305 | 135 | options += " OR at.code = 'tax'" | ||
306 | 136 | options += ')' | ||
307 | 137 | else: | ||
308 | 138 | options = '' | ||
309 | 139 | self.sql = self.sql.replace('{options}', options) | ||
310 | 140 | 148 | ||
311 | 141 | def output(self): | 149 | def output(self): |
312 | 142 | """ | 150 | """ |
313 | @@ -169,28 +177,31 @@ | |||
314 | 169 | 177 | ||
315 | 170 | level = self._move_level | 178 | level = self._move_level |
316 | 171 | while level > 0: | 179 | while level > 0: |
329 | 172 | nodes = self.nodes_by_level[level] | 180 | nodes = self.nodes_by_level.get(level) |
330 | 173 | for n in nodes: | 181 | if nodes: |
331 | 174 | if level == self._move_level: | 182 | for n in nodes: |
332 | 175 | if self.with_balance_only: | 183 | if level == self._move_level: |
333 | 176 | bal = n.data.get('*', {}).get('debit', 0.) \ | 184 | if self.with_balance_only: |
334 | 177 | - n.data.get('*', {}).get('credit', 0.) | 185 | bal = n.data.get('*', {}).get('debit', 0.) \ |
335 | 178 | if bal == 0.: | 186 | - n.data.get('*', {}).get('credit', 0.) |
336 | 179 | # JI level: | 187 | if bal == 0.: |
337 | 180 | # with only balance filter: do not agregate account | 188 | # JI level: |
338 | 181 | # debit/credit with a zero balance | 189 | # with only balance filter: do not agregate account |
339 | 182 | n.zero_bal = True | 190 | # debit/credit with a zero balance |
340 | 183 | continue | 191 | n.zero_bal = True |
341 | 192 | continue | ||
342 | 193 | elif level == self._move_level - 1: | ||
343 | 194 | n.skip = not n.childs # no entries due to filtering | ||
344 | 184 | 195 | ||
350 | 185 | parent = n.parent | 196 | parent = n.parent |
351 | 186 | if parent: | 197 | if parent: |
352 | 187 | for ccy in n.data: | 198 | for ccy in n.data: |
353 | 188 | if not ccy in parent.data: | 199 | if not ccy in parent.data: |
354 | 189 | parent.data[ccy] = {} | 200 | parent.data[ccy] = {} |
355 | 201 | for f in fields: | ||
356 | 202 | parent.data[ccy][f] = 0. | ||
357 | 190 | for f in fields: | 203 | for f in fields: |
361 | 191 | parent.data[ccy][f] = 0. | 204 | parent.data[ccy][f] += n.data[ccy].get(f, 0.) |
359 | 192 | for f in fields: | ||
360 | 193 | parent.data[ccy][f] += n.data[ccy].get(f, 0.) | ||
362 | 194 | level -= 1 # upper level (upper level by uper level) | 205 | level -= 1 # upper level (upper level by uper level) |
363 | 195 | 206 | ||
364 | 196 | # uncomment to explore reduced nodes | 207 | # uncomment to explore reduced nodes |
365 | @@ -211,10 +222,13 @@ | |||
366 | 211 | child_ids = self._search(domain) | 222 | child_ids = self._search(domain) |
367 | 212 | if child_ids: | 223 | if child_ids: |
368 | 213 | for id in child_ids: | 224 | for id in child_ids: |
370 | 214 | if not self.include_accounts or id in self.include_accounts: | 225 | create = level < self._move_level \ |
371 | 226 | or not self.include_accounts or id in self.include_accounts | ||
372 | 227 | if create: | ||
373 | 215 | node = self._create_node(parent=parent, level=level, | 228 | node = self._create_node(parent=parent, level=level, |
374 | 216 | account_id=id) | 229 | account_id=id) |
376 | 217 | self._map_dive(node, level + 1) | 230 | if node: |
377 | 231 | self._map_dive(node, level + 1) | ||
378 | 218 | 232 | ||
379 | 219 | def _create_node(self, parent=None, level=0, account_id=False): | 233 | def _create_node(self, parent=None, level=0, account_id=False): |
380 | 220 | """ | 234 | """ |