Merge lp:~vauxoo/account-financial-report/afr_multicurrency_hbto into lp:~vauxoo/account-financial-report/trunk

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Merged
Merged at revision: 17
Proposed branch: lp:~vauxoo/account-financial-report/afr_multicurrency_hbto
Merge into: lp:~vauxoo/account-financial-report/trunk
Diff against target: 486 lines (+139/-69)
10 files modified
account_financial_report/report/account_balance.py (+39/-20)
account_financial_report/report/account_balance_2_cols.py (+43/-22)
account_financial_report/report/account_balance_4_cols.py (+38/-21)
account_financial_report/report/balance_full.rml (+1/-1)
account_financial_report/report/balance_full_2_cols.rml (+1/-1)
account_financial_report/report/balance_full_4_cols.rml (+1/-1)
account_financial_report/wizard/account_report_wizard.xml (+13/-3)
account_financial_report/wizard/wizard_account_balance_2_report.py (+1/-0)
account_financial_report/wizard/wizard_account_balance_4_report.py (+1/-0)
account_financial_report/wizard/wizard_account_balance_report.py (+1/-0)
To merge this branch: bzr merge lp:~vauxoo/account-financial-report/afr_multicurrency_hbto
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+111537@code.launchpad.net

Description of the change

En esta nueva aproximacion de Reportes Financieros,

Se ha agregado un campo de Moneda Secundaria,

que le permite al usuario generar los reportes

en otra moneda distinta a la que tiene configurada

la compania

Se ha tambien hecho la revision para que
este reporte funcione de manera indistinta
tanto en la v6.0 como en la v6.1

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :

Aprobado

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/account_balance.py'
2--- account_financial_report/report/account_balance.py 2012-02-24 19:18:16 +0000
3+++ account_financial_report/report/account_balance.py 2012-06-22 05:13:25 +0000
4@@ -55,6 +55,7 @@
5 'get_periods_and_date_text': self.get_periods_and_date_text,
6 'get_informe_text': self.get_informe_text,
7 'get_month':self.get_month,
8+ 'exchange_name':self.exchange_name,
9 })
10 self.context = context
11
12@@ -121,20 +122,41 @@
13
14 return {'periods':periods_str, 'date':dates_str}
15
16-
17- def lines(self, form, ids={}, done=None, level=0):
18+ def exchange_name(self, form):
19+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
20+ if not form['currency_id']:
21+ self.to_currency_id = self.from_currency_id
22+ else:
23+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
24+ return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name
25+
26+ def exchange(self, from_amount):
27+ if self.from_currency_id == self.to_currency_id:
28+ return from_amount
29+ curr_obj = self.pool.get('res.currency')
30+ return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount)
31+
32+ def get_company_currency(self, company_id):
33+ rc_obj = self.pool.get('res.company')
34+ return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id
35+
36+
37+ def lines(self, form, level=0):
38 """
39 Returns all the data needed for the report lines
40 (account info plus debit/credit/balance in the selected period
41 and the full year)
42 """
43+
44+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
45+ if not form['currency_id']:
46+ self.to_currency_id = self.from_currency_id
47+ else:
48+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
49+
50+ tot_check = False
51 tot_eje = 0.0
52- if not ids:
53- ids = self.ids
54- if not ids:
55- return []
56- if not done:
57- done = {}
58+
59 if form.has_key('account_list') and form['account_list']:
60 account_ids = form['account_list']
61 del form['account_list']
62@@ -146,11 +168,12 @@
63 fiscalyear_obj = self.pool.get('account.fiscalyear')
64
65 # Get the fiscal year
66- fiscalyear = None
67 if form.get('fiscalyear'):
68- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])
69- else:
70- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
71+ if type(form.get('fiscalyear')) in (list,tuple):
72+ fiscalyear = form['fiscalyear'] and form['fiscalyear'][0]
73+ elif type(form.get('fiscalyear')) in (int,):
74+ fiscalyear = form['fiscalyear']
75+ fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear)
76
77 #
78 # Get the accounts
79@@ -241,11 +264,6 @@
80 for account in accounts:
81 account_id = account['id']
82
83- if account_id in done:
84- pass
85-
86- done[account_id] = 1
87-
88 #
89 # Calculate the account level
90 #
91@@ -265,7 +283,7 @@
92 'code': account['code'],
93 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],
94 'level': account['level'],
95- 'balance': account['balance'],
96+ 'balance': self.exchange(account['balance']),
97 'parent_id': account['parent_id'],
98 'bal_type': '',
99 'label': account['label'],
100@@ -295,14 +313,15 @@
101 # Include all accounts
102 result_acc.append(res)
103 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
104+ tot_check = True
105 tot[res['id']] = True
106 tot_eje += res['balance']
107- if form['tot_check']:
108+ if tot_check:
109 str_label = form['lab_str']
110 res2 = {
111 'type' : 'view',
112 'name': 'TOTAL %s'%(str_label),
113- 'balance': tot_eje,
114+ 'balance': self.exchange(tot_eje),
115 'label': False,
116 'total': True,
117 }
118
119=== modified file 'account_financial_report/report/account_balance_2_cols.py'
120--- account_financial_report/report/account_balance_2_cols.py 2012-02-24 19:18:16 +0000
121+++ account_financial_report/report/account_balance_2_cols.py 2012-06-22 05:13:25 +0000
122@@ -55,6 +55,7 @@
123 'get_periods_and_date_text': self.get_periods_and_date_text,
124 'get_informe_text': self.get_informe_text,
125 'get_month':self.get_month,
126+ 'exchange_name':self.exchange_name,
127 })
128 self.context = context
129
130@@ -122,22 +123,46 @@
131 return {'periods':periods_str, 'date':dates_str}
132
133
134- def lines(self, form, ids={}, done=None, level=0):
135+
136+ def exchange_name(self, form):
137+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
138+ if not form['currency_id']:
139+ self.to_currency_id = self.from_currency_id
140+ else:
141+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
142+ return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name
143+
144+ def exchange(self, from_amount):
145+ if self.from_currency_id == self.to_currency_id:
146+ return from_amount
147+ curr_obj = self.pool.get('res.currency')
148+ return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount)
149+
150+ def get_company_currency(self, company_id):
151+ rc_obj = self.pool.get('res.company')
152+ return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id
153+
154+
155+
156+ def lines(self, form, level=0):
157 """
158 Returns all the data needed for the report lines
159 (account info plus debit/credit/balance in the selected period
160 and the full year)
161 """
162+
163+
164+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
165+ if not form['currency_id']:
166+ self.to_currency_id = self.from_currency_id
167+ else:
168+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
169+
170+ tot_check = False
171 tot_bin = 0.0
172 tot_deb = 0.0
173 tot_crd = 0.0
174 tot_eje = 0.0
175- if not ids:
176- ids = self.ids
177- if not ids:
178- return []
179- if not done:
180- done = {}
181
182 if form.has_key('account_list') and form['account_list']:
183 account_ids = form['account_list']
184@@ -149,12 +174,12 @@
185 period_obj = self.pool.get('account.period')
186 fiscalyear_obj = self.pool.get('account.fiscalyear')
187
188- fiscalyear = None
189 if form.get('fiscalyear'):
190- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])
191- else:
192- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
193-
194+ if type(form.get('fiscalyear')) in (list,tuple):
195+ fiscalyear = form['fiscalyear'] and form['fiscalyear'][0]
196+ elif type(form.get('fiscalyear')) in (int,):
197+ fiscalyear = form['fiscalyear']
198+ fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear)
199 #
200 # Get the accounts
201 #
202@@ -260,11 +285,6 @@
203 for account in accounts:
204 account_id = account['id']
205
206- if account_id in done:
207- pass
208-
209- done[account_id] = 1
210-
211 accounts_levels[account_id] = account['level']
212
213 #
214@@ -280,10 +300,10 @@
215 'code': account['code'],
216 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],
217 'level': account['level'],
218- 'balanceinit': period_balanceinit[account_id],
219- 'debit': account['debit'],
220- 'credit': account['credit'],
221- 'balance': period_balanceinit[account_id]+account['debit']-account['credit'],
222+ 'balanceinit': self.exchange(period_balanceinit[account_id]),
223+ 'debit': self.exchange(account['debit']),
224+ 'credit': self.exchange(account['credit']),
225+ 'balance': self.exchange(period_balanceinit[account_id]+account['debit']-account['credit']),
226 'parent_id': account['parent_id'],
227 'bal_type': '',
228 'label': account['label'],
229@@ -312,13 +332,14 @@
230 # Include all accounts
231 result_acc.append(res)
232 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
233+ tot_check = True
234 tot[res['id']] = True
235 tot_bin += res['balanceinit']
236 tot_deb += res['debit']
237 tot_crd += res['credit']
238 tot_eje += res['balance']
239
240- if form['tot_check']:
241+ if tot_check:
242 str_label = form['lab_str']
243 res2 = {
244 'type' : 'view',
245
246=== modified file 'account_financial_report/report/account_balance_4_cols.py'
247--- account_financial_report/report/account_balance_4_cols.py 2012-04-16 16:05:22 +0000
248+++ account_financial_report/report/account_balance_4_cols.py 2012-06-22 05:13:25 +0000
249@@ -55,6 +55,7 @@
250 'get_periods_and_date_text': self.get_periods_and_date_text,
251 'get_informe_text': self.get_informe_text,
252 'get_month':self.get_month,
253+ 'exchange_name':self.exchange_name,
254 })
255 self.context = context
256
257@@ -129,23 +130,42 @@
258 if not period_counter:
259 return True
260 return False
261+
262+ def exchange_name(self, form):
263+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
264+ if not form['currency_id']:
265+ self.to_currency_id = self.from_currency_id
266+ else:
267+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
268+ name = self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name
269+ return self.pool.get('res.currency').browse(self.cr, self.uid, self.to_currency_id).name
270
271- def lines(self, form, ids={}, done=None, level=0):
272+ def exchange(self, from_amount):
273+ if self.from_currency_id == self.to_currency_id:
274+ return from_amount
275+ curr_obj = self.pool.get('res.currency')
276+ return curr_obj.compute(self.cr, self.uid, self.from_currency_id, self.to_currency_id, from_amount)
277+
278+ def get_company_currency(self, company_id):
279+ rc_obj = self.pool.get('res.company')
280+ return rc_obj.browse(self.cr, self.uid, company_id).currency_id.id
281+
282+ def lines(self, form, level=0):
283 """
284 Returns all the data needed for the report lines
285 (account info plus debit/credit/balance in the selected period
286 and the full year)
287 """
288+ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form['company_id']) in (list,tuple) and form['company_id'][0] or form['company_id'])
289+ if not form['currency_id']:
290+ self.to_currency_id = self.from_currency_id
291+ else:
292+ self.to_currency_id = form['currency_id'] and type(form['currency_id']) in (list, tuple) and form['currency_id'][0] or form['currency_id']
293+ tot_check = False
294 tot_bin = 0.0
295 tot_deb = 0.0
296 tot_crd = 0.0
297 tot_eje = 0.0
298- if not ids:
299- ids = self.ids
300- if not ids:
301- return []
302- if not done:
303- done = {}
304
305 if form.has_key('account_list') and form['account_list']:
306 account_ids = form['account_list']
307@@ -157,11 +177,12 @@
308 period_obj = self.pool.get('account.period')
309 fiscalyear_obj = self.pool.get('account.fiscalyear')
310
311- fiscalyear = None
312 if form.get('fiscalyear'):
313- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])
314- else:
315- fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
316+ if type(form.get('fiscalyear')) in (list,tuple):
317+ fiscalyear = form['fiscalyear'] and form['fiscalyear'][0]
318+ elif type(form.get('fiscalyear')) in (int,):
319+ fiscalyear = form['fiscalyear']
320+ fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear)
321
322 #
323 # Get the accounts
324@@ -280,11 +301,6 @@
325 for account in accounts:
326 account_id = account['id']
327
328- if account_id in done:
329- pass
330-
331- done[account_id] = 1
332-
333 accounts_levels[account_id] = account['level']
334
335 #
336@@ -300,10 +316,10 @@
337 'code': account['code'],
338 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],
339 'level': account['level'],
340- 'balanceinit': period_balanceinit[account_id],
341- 'debit': account['debit'],
342- 'credit': account['credit'],
343- 'balance': period_balanceinit[account_id]+account['debit']-account['credit'],
344+ 'balanceinit': self.exchange(period_balanceinit[account_id]),
345+ 'debit': self.exchange(account['debit']),
346+ 'credit': self.exchange(account['credit']),
347+ 'balance': self.exchange(period_balanceinit[account_id]+account['debit']-account['credit']),
348 'parent_id': account['parent_id'],
349 'bal_type': '',
350 'label': account['label'],
351@@ -332,6 +348,7 @@
352 # Include all accounts
353 result_acc.append(res)
354 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
355+ tot_check = True
356 tot[res['id']] = True
357 tot_bin += res['balanceinit']
358 tot_deb += res['debit']
359@@ -339,7 +356,7 @@
360 tot_eje += res['balance']
361
362 #if (form['tot_check'] and res['type']=='view' and res['level']==1 and (res['id'] not in tot)):
363- if form['tot_check']:
364+ if tot_check:
365 str_label = form['lab_str']
366 res2 = {
367 'type' : 'view',
368
369=== modified file 'account_financial_report/report/balance_full.rml'
370--- account_financial_report/report/balance_full.rml 2012-01-20 23:34:50 +0000
371+++ account_financial_report/report/balance_full.rml 2012-06-22 05:13:25 +0000
372@@ -16,7 +16,7 @@
373 </tr>
374 <tr>
375 <td><para style="TOP_TITLE"></para></td>
376- <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
377+ <td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
378 </tr>
379 <tr>
380 <td><para style="TOP_TITLE"></para></td>
381
382=== modified file 'account_financial_report/report/balance_full_2_cols.rml'
383--- account_financial_report/report/balance_full_2_cols.rml 2012-02-09 21:28:52 +0000
384+++ account_financial_report/report/balance_full_2_cols.rml 2012-06-22 05:13:25 +0000
385@@ -20,7 +20,7 @@
386 </tr>
387 <tr>
388 <td><para style="TOP_TITLE"></para></td>
389- <td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
390+ <td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
391 </tr>
392 <tr>
393 <td><para style="TOP_TITLE"></para></td>
394
395=== modified file 'account_financial_report/report/balance_full_4_cols.rml'
396--- account_financial_report/report/balance_full_4_cols.rml 2012-02-09 21:16:17 +0000
397+++ account_financial_report/report/balance_full_4_cols.rml 2012-06-22 05:13:25 +0000
398@@ -26,7 +26,7 @@
399 </tr>
400 <tr>
401 <td><para style="TOP_TITLE"></para></td>
402- <td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
403+ <td><para style="TITLE_CENTER">[[data['form'] and (' (Expresado en %s)'%( exchange_name(data['form']))) or '']]</para></td>
404 </tr>
405 <tr>
406 <td><para style="TOP_TITLE"></para></td>
407
408=== modified file 'account_financial_report/wizard/account_report_wizard.xml'
409--- account_financial_report/wizard/account_report_wizard.xml 2012-03-21 17:34:58 +0000
410+++ account_financial_report/wizard/account_report_wizard.xml 2012-06-22 05:13:25 +0000
411@@ -8,8 +8,11 @@
412 <field name="type">form</field>
413 <field name="arch" type="xml">
414 <form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
415- <group width='800' height='600'>
416+ <group>
417 <field name="company_id"/>
418+ <group>
419+ <field name="currency_id"/>
420+ </group>
421
422 <newline/>
423 <group colspan="4">
424@@ -75,8 +78,11 @@
425 <field name="type">form</field>
426 <field name="arch" type="xml">
427 <form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
428- <group width='800' height='600'>
429+ <group>
430 <field name="company_id"/>
431+ <group>
432+ <field name="currency_id"/>
433+ </group>
434 <newline/>
435 <group colspan="4">
436 <separator string="Accounts to include" colspan="4"/>
437@@ -138,8 +144,12 @@
438 <field name="type">form</field>
439 <field name="arch" type="xml">
440 <form string="General Account Balance [ Initial | Debit | Credit | Balance ]">
441- <group width='800' height='600'>
442+ <group>
443 <field name="company_id"/>
444+ <group>
445+ <field name="currency_id"/>
446+ </group>
447+
448 <newline/>
449 <group colspan="4">
450 <separator string="Accounts to include" colspan="4"/>
451
452=== modified file 'account_financial_report/wizard/wizard_account_balance_2_report.py'
453--- account_financial_report/wizard/wizard_account_balance_2_report.py 2012-05-25 16:13:27 +0000
454+++ account_financial_report/wizard/wizard_account_balance_2_report.py 2012-06-22 05:13:25 +0000
455@@ -48,6 +48,7 @@
456 'lab_str': fields.char('Description', size= 128),
457 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bdl','Diario Legal')],'Tipo Informe',required=True),
458 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
459+ 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
460 }
461
462 _defaults = {
463
464=== modified file 'account_financial_report/wizard/wizard_account_balance_4_report.py'
465--- account_financial_report/wizard/wizard_account_balance_4_report.py 2012-05-25 16:13:27 +0000
466+++ account_financial_report/wizard/wizard_account_balance_4_report.py 2012-06-22 05:13:25 +0000
467@@ -48,6 +48,7 @@
468 'lab_str': fields.char('Description', size= 128),
469 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True),
470 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
471+ 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
472 }
473
474 _defaults = {
475
476=== modified file 'account_financial_report/wizard/wizard_account_balance_report.py'
477--- account_financial_report/wizard/wizard_account_balance_report.py 2012-05-25 16:13:27 +0000
478+++ account_financial_report/wizard/wizard_account_balance_report.py 2012-06-22 05:13:25 +0000
479@@ -48,6 +48,7 @@
480 'lab_str': fields.char('Description', size= 128),
481 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
482 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
483+ 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all values for this report to be expressed in this secondary currency."),
484 }
485
486 _defaults = {

Subscribers

People subscribed via source and target branches

to all changes: