Merge lp:~unifield-team/unifield-server/us-1197 into lp:unifield-server

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
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+291888@code.launchpad.net
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 'show_period_0': 1,
6 'state_agnostic': 1,
7 })
8+ # US-1197/4: IB entries for yearly closing always in 1th Jan
9+ # => get rid of regular period/dates filters for _query_get
10+ # => if self.init_balance is True, note that filtering is OK
11+ # validated at wizard report level
12+ ib_local_context.update({
13+ 'date_from': False,
14+ 'date_to': False,
15+ 'date_fromto_docdate': False,
16+ 'period_from': False,
17+ 'period_to': False,
18+ 'periods': False,
19+ })
20 self.init_query = obj_move._query_get(self.cr, self.uid, obj='l',
21 context=ib_local_context)
22 else:
23@@ -226,12 +238,18 @@
24
25 def _show_node_in_report(self, node):
26 res = True
27- if self.account_ids or self.unreconciled_filter:
28- # hide if zero bal and any by account or unreconciled filter on
29- bal = node.data.get('*', {}).get('debit', 0.) \
30- - node.data.get('*', {}).get('credit', 0.)
31- if bal == 0.:
32- res = False
33+ if node.parent is None:
34+ return res # always show root account MSF
35+ if self.account_ids or self.account_report_types \
36+ or self.unreconciled_filter:
37+ res = not node.skip
38+ if res:
39+ # hide if zero bal and any by account or unreconciled filter on
40+ bal = node.data.get('*', {}).get('debit', 0.) \
41+ - node.data.get('*', {}).get('credit', 0.)
42+ if bal == 0.:
43+ res = False
44+
45 return res
46
47 def _get_journals_str(self, data):
48@@ -393,6 +411,7 @@
49 line = self.get_start_period(data) + ' - ' + self.get_end_period(data)
50 if line:
51 infos.append(line)
52+
53 return infos and ", \n".join(infos) or _('No Filter')
54
55 def _get_line_debit(self, line, booking=False):
56@@ -479,6 +498,15 @@
57 display_account = _('With balance is not equal to 0')
58 info_data.append((_('Accounts'), display_account, ))
59
60+ account_ids = list(set(self._get_data_form(data, 'account_ids')))
61+ if account_ids:
62+ # US-1197/2: display filtered accounts
63+ account_obj = self.pool.get('account.account')
64+ info_data.append((_('Selected Accounts'), ', '.join(
65+ [ a.code for a in account_obj.browse(
66+ self.cr, self.uid, account_ids) \
67+ if a.type != 'view' ], )))
68+
69 res = [ "%s: %s" % (label, val, ) for label, val in info_data ]
70 return ', \n'.join(res)
71
72
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 [[ get_show_move_lines() or removeParentNode('blockTable') ]]
78 <tr>
79 <td>
80- <para style="terp_tblheader_Details">Entry Seq</para>
81+ <para style="terp_tblheader_Details">Account/Entry Seq</para>
82 </td>
83 <td>
84 <para style="terp_tblheader_Details">Posting Date</para>
85@@ -330,14 +330,17 @@
86
87 <section>
88 <para style="terp_default_8">[[ repeatIn(lines(o, initial_balance_mode=True), 'line') ]]</para>
89- <blockTable colWidths="286.0,60.0,110.0,110.0,110.0,110.0" style="Table9">
90+ <blockTable colWidths="40.0,246.0,60.0,110.0,110.0,110.0,110.0" style="Table9">
91 [[ show_node_in_report(o) or removeParentNode('blockTable') ]]
92 <tr>
93 <td>
94+ <para style="terp_default_9_Right">[[ o.code or '' ]]</para>
95+ </td>
96+ <td>
97 <para style="terp_default_9_Right">[[ line['move'] or '' ]]</para>
98 </td>
99 <td>
100- <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>
101+ <para style="terp_default_9_Right">[[ line['currency_name'] or '' ]]</para>
102 </td>
103 <td>
104 <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
107 <section>
108 <para style="terp_default_8">[[ repeatIn(o.get_currencies(), 'ccy') ]]</para>
109- <blockTable colWidths="286.0,60.0,110.0,110.0,110.0,110.0" style="Table8_subtotal_ccy">
110+ <blockTable colWidths="40.0,246.0,60.0,110.0,110.0,110.0,110.0" style="Table8_subtotal_ccy">
111 [[ show_node_in_report(o) or removeParentNode('blockTable') ]]
112 <tr>
113 <td>
114- <para style="terp_default_9_Right">[[ o.code ]]</para>
115+ <para style="terp_default_9_Right">[[ o.code or '' ]]</para>
116+ </td>
117+ <td>
118+ <para style="terp_default_9_Right">Sub Total</para>
119 </td>
120 <td>
121 <para style="terp_default_9_Right">[[ ccy ]]</para>
122
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 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 %>
129 <Table x:FullColumns="1" x:FullRows="1">
130-<Column ss:AutoFitWidth="1" ss:Width="64" />
131-<Column ss:AutoFitWidth="1" ss:Width="120" />
132-<Column ss:AutoFitWidth="1" ss:Width="64" />
133-% if get_show_move_lines():
134-<Column ss:AutoFitWidth="1" ss:Width="300" />
135-% endif
136-% if not get_show_move_lines():
137-<Column ss:AutoFitWidth="1" ss:Width="150" />
138-% endif
139-<Column ss:AutoFitWidth="1" ss:Width="50" />
140-<Column ss:AutoFitWidth="1" ss:Width="64" />
141-<Column ss:AutoFitWidth="1" ss:Width="64" />
142-<Column ss:AutoFitWidth="1" ss:Width="64" />
143-<Column ss:AutoFitWidth="1" ss:Width="64" />
144-<Column ss:AutoFitWidth="1" ss:Width="64" />
145+<Column ss:AutoFitWidth="1" ss:Width="50" />
146+<Column ss:AutoFitWidth="1" ss:Width="80" />
147+<Column ss:AutoFitWidth="1" ss:Width="55" />
148+<Column ss:AutoFitWidth="1" ss:Width="80" />
149+<Column ss:AutoFitWidth="1" ss:Width="50" />
150+<Column ss:Width="90" />
151+<Column ss:Width="90" />
152+<Column ss:Width="90" />
153+<Column ss:Width="90" />
154 <Row>
155 <Cell ss:StyleID="ssH"><Data ss:Type="String">${header_company_or_chart_of_account}</Data></Cell>
156 <Cell ss:StyleID="ssH"><Data ss:Type="String">Fiscal Year</Data></Cell>
157@@ -246,13 +240,14 @@
158 </Row>
159 <Row>
160 % if get_show_move_lines():
161-<Cell ss:StyleID="ssH" ss:MergeAcross="1"><Data ss:Type="String">Entry Seq</Data></Cell>
162+<Cell ss:StyleID="ssH"><Data ss:Type="String">Account</Data></Cell>
163+<Cell ss:StyleID="ssH"><Data ss:Type="String">Entry Seq</Data></Cell>
164 <Cell ss:StyleID="ssH"><Data ss:Type="String">Posting Date</Data></Cell>
165 <Cell ss:StyleID="ssH"><Data ss:Type="String">Description</Data></Cell>
166 <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell>
167 % endif
168 % if not get_show_move_lines():
169-<Cell ss:StyleID="ssH"><Data ss:Type="String">Account / CCY</Data></Cell>
170+<Cell ss:StyleID="ssH"><Data ss:Type="String">Account</Data></Cell>
171 <Cell ss:StyleID="ssH" ss:MergeAcross="2"><Data ss:Type="String"></Data></Cell>
172 <Cell ss:StyleID="ssH"><Data ss:Type="String">Currency</Data></Cell>
173 % endif
174@@ -301,7 +296,10 @@
175
176 % for line in lines(o, initial_balance_mode=True):
177 <Row>
178-<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="3">
179+<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}">
180+ <Data ss:Type="String">${(o.code or '')|x}</Data>
181+</Cell>
182+<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="2">
183 <Data ss:Type="String">${(line['move'] or '' or '')|x}</Data>
184 </Cell>
185 <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}">
186@@ -333,7 +331,7 @@
187 <Cell ss:StyleID="ssAccountLine">
188 <Data ss:Type="String">${(formatLang(line['ldate'],date=True)) or ''}</Data>
189 </Cell>
190-<Cell ss:StyleID="ssAccountLineNoWrap">
191+<Cell ss:StyleID="ssAccountLine">
192 <Data ss:Type="String">${(line['lname'] or '')|x}</Data>
193 </Cell>
194 <Cell ss:StyleID="ssAccountLine">
195@@ -356,9 +354,12 @@
196
197 % for ccy in o.get_currencies():
198 <Row>
199-<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="3">
200+<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}">
201 <Data ss:Type="String">${(o.code or '')|x}</Data>
202 </Cell>
203+<Cell ss:StyleID="ssBorder${ccy_sub_total_style_suffix}${ccy_sub_total_style_right_suffix}" ss:MergeAcross="2">
204+ <Data ss:Type="String">Sub Total</Data>
205+</Cell>
206 <Cell ss:StyleID="ssAccountLine${ccy_sub_total_style_suffix}">
207 <Data ss:Type="String">${(ccy or '')|x}</Data>
208 </Cell>
209@@ -383,7 +384,12 @@
210 <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
211 <PageSetup>
212 <Layout x:Orientation="Landscape"/>
213- <Header x:Data="&amp;C&amp;&quot;Arial,Bold&quot;&amp;14General Ledger"/>
214+% if get_show_move_lines():
215+ <Header x:Data="&amp;C&amp;&quot;Arial,Bold&quot;&amp;14General Ledger"/>0
216+% endif
217+% if not get_show_move_lines():
218+ <Header x:Data="&amp;C&amp;&quot;Arial,Bold&quot;&amp;14Trial Balance"/>0
219+% endif
220 <Footer x:Data="Page &amp;P of &amp;N"/>
221 </PageSetup>
222 <Print>
223
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 fy_rec = self.pool.get('account.fiscalyear').browse(cr, uid,
229 fiscalyear_id, context=context)
230 if filter in ('filter_date_doc', 'filter_date', ):
231- ib_available = date_from and date_to \
232- and date_from == fy_rec.date_start \
233- and date_to <= fy_rec.date_stop
234+ ib_available = date_from and date_from == fy_rec.date_start
235 elif filter in 'filter_period':
236 if not period_from or not period_to:
237 ib_available = False
238
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 # set during map/reduce
244 self.data = {}
245 self.zero_bal = False
246+ self.skip = False
247
248 # set during next_node() calls
249 self.code = ''
250@@ -80,12 +81,11 @@
251 JOIN res_currency c ON (c.id = l.currency_id)
252 JOIN account_journal j on (l.journal_id=j.id)
253 JOIN account_account a on (a.id=l.account_id)
254- JOIN account_account_type at on (at.id=a.user_type)
255- WHERE l.account_id = %s{reconcile}{options}{query}
256+ WHERE l.account_id = %s{reconcile}{query}
257 GROUP BY l.currency_id'''
258
259 # initial balance move lines base query (from IB journal period 0)
260- _sql_ib = '''SELECT sum(debit), sum(credit),
261+ _sql_ib = '''SELECT sum(debit), sum(credit),
262 sum(debit_currency), sum(credit_currency),
263 max(c.name)
264 FROM account_move_line l
265@@ -112,8 +112,28 @@
266 self.query_ib = query_ib or ''
267 self.move_states = move_states or [ 'draft', 'posted', ]
268 self.include_accounts = include_accounts
269+ self.account_report_types = account_report_types
270 self.with_balance_only = with_balance_only
271 self.reconcile_filter = reconcile_filter
272+ if self.account_report_types and not self.include_accounts:
273+ # deduce included accounts from report type filter
274+ domain = [
275+ ('report_type', 'in' , self.account_report_types),
276+ ]
277+ if 'asset' in self.account_report_types \
278+ or 'liability' in self.account_report_types:
279+ # US-227 include tax account for BS accounts selection
280+ domain = [ '|', ('code', '=', 'tax') ] + domain
281+ account_types_ids = self.pool.get('account.account.type').search(
282+ self.cr, self.uid, domain, context=self.context)
283+
284+ if account_types_ids:
285+ domain = [
286+ ('type', '!=', 'view'),
287+ ('user_type', 'in' , account_types_ids),
288+ ]
289+ self.include_accounts = self.pool.get('account.account').search(
290+ self.cr, self.uid, domain, context=self.context) or []
291
292 # nodes
293 self.root = None
294@@ -125,18 +145,6 @@
295 # JI base query: constructed via _sql
296 self.sql = self._sql
297 self.sql = self.sql.replace('{reconcile}', self.reconcile_filter)
298- if account_report_types:
299- report_types = [ "'%s'" % (rt, ) for rt in account_report_types ]
300- options = " AND (at.report_type in (%s)" % (
301- ','.join(report_types), )
302- if 'asset' in account_report_types \
303- or 'liability' in account_report_types:
304- # US-227 include tax account for BS accounts selection
305- options += " OR at.code = 'tax'"
306- options += ')'
307- else:
308- options = ''
309- self.sql = self.sql.replace('{options}', options)
310
311 def output(self):
312 """
313@@ -169,28 +177,31 @@
314
315 level = self._move_level
316 while level > 0:
317- nodes = self.nodes_by_level[level]
318- for n in nodes:
319- if level == self._move_level:
320- if self.with_balance_only:
321- bal = n.data.get('*', {}).get('debit', 0.) \
322- - n.data.get('*', {}).get('credit', 0.)
323- if bal == 0.:
324- # JI level:
325- # with only balance filter: do not agregate account
326- # debit/credit with a zero balance
327- n.zero_bal = True
328- continue
329+ nodes = self.nodes_by_level.get(level)
330+ if nodes:
331+ for n in nodes:
332+ if level == self._move_level:
333+ if self.with_balance_only:
334+ bal = n.data.get('*', {}).get('debit', 0.) \
335+ - n.data.get('*', {}).get('credit', 0.)
336+ if bal == 0.:
337+ # JI level:
338+ # with only balance filter: do not agregate account
339+ # debit/credit with a zero balance
340+ n.zero_bal = True
341+ continue
342+ elif level == self._move_level - 1:
343+ n.skip = not n.childs # no entries due to filtering
344
345- parent = n.parent
346- if parent:
347- for ccy in n.data:
348- if not ccy in parent.data:
349- parent.data[ccy] = {}
350+ parent = n.parent
351+ if parent:
352+ for ccy in n.data:
353+ if not ccy in parent.data:
354+ parent.data[ccy] = {}
355+ for f in fields:
356+ parent.data[ccy][f] = 0.
357 for f in fields:
358- parent.data[ccy][f] = 0.
359- for f in fields:
360- parent.data[ccy][f] += n.data[ccy].get(f, 0.)
361+ parent.data[ccy][f] += n.data[ccy].get(f, 0.)
362 level -= 1 # upper level (upper level by uper level)
363
364 # uncomment to explore reduced nodes
365@@ -211,10 +222,13 @@
366 child_ids = self._search(domain)
367 if child_ids:
368 for id in child_ids:
369- if not self.include_accounts or id in self.include_accounts:
370+ create = level < self._move_level \
371+ or not self.include_accounts or id in self.include_accounts
372+ if create:
373 node = self._create_node(parent=parent, level=level,
374 account_id=id)
375- self._map_dive(node, level + 1)
376+ if node:
377+ self._map_dive(node, level + 1)
378
379 def _create_node(self, parent=None, level=0, account_id=False):
380 """

Subscribers

People subscribed via source and target branches

to all changes: