Merge lp:~vauxoo/account-financial-report/miguel-bug-918857 into lp:~vauxoo/account-financial-report/trunk

Proposed by Miguel Delgado (Vauxoo)
Status: Merged
Merged at revision: 6
Proposed branch: lp:~vauxoo/account-financial-report/miguel-bug-918857
Merge into: lp:~vauxoo/account-financial-report/trunk
Diff against target: 1247 lines (+392/-247)
10 files modified
account_financial_report/report/account_balance.py (+24/-21)
account_financial_report/report/account_balance_2_cols.py (+99/-57)
account_financial_report/report/account_balance_4_cols.py (+29/-26)
account_financial_report/report/balance_full.rml (+11/-22)
account_financial_report/report/balance_full_2_cols.rml (+14/-38)
account_financial_report/report/balance_full_4_cols.rml (+11/-16)
account_financial_report/wizard/account_report_wizard.xml (+12/-12)
account_financial_report/wizard/wizard_account_balance_2_report.py (+55/-19)
account_financial_report/wizard/wizard_account_balance_4_report.py (+83/-18)
account_financial_report/wizard/wizard_account_balance_report.py (+54/-18)
To merge this branch: bzr merge lp:~vauxoo/account-financial-report/miguel-bug-918857
Reviewer Review Type Date Requested Status
Gabriela Quilarque Pending
Review via email: mp+89508@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 'account_financial_report/report/account_balance.py'
2--- account_financial_report/report/account_balance.py 2012-01-02 22:27:49 +0000
3+++ account_financial_report/report/account_balance.py 2012-01-20 23:38:23 +0000
4@@ -53,8 +53,8 @@
5 'lines': self.lines,
6 'get_fiscalyear_text': self.get_fiscalyear_text,
7 'get_periods_and_date_text': self.get_periods_and_date_text,
8- 'get_inf_text': self.get_informe_text,
9- 'get_month':self._get_month,
10+ 'get_informe_text': self.get_informe_text,
11+ 'get_month':self.get_month,
12 })
13 self.context = context
14
15@@ -72,21 +72,25 @@
16 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
17 return "%s*" % (fiscalyear.name or fiscalyear.code)
18
19- def _get_month(self, form):
20+ def get_month(self, form):
21 '''
22 return day, year and month
23 '''
24-
25- months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
26-
27- mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
28- ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
29- dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
30-
31- if form['inf_type']=='edogp':
32- return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)
33- else:
34- return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)
35+ if form['filter'] in ['bydate', 'all']:
36+ months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
37+ mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
38+ ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
39+ dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
40+ return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
41+ elif form['filter'] in ['byperiod', 'all']:
42+ aux=[]
43+ period_obj = self.pool.get('account.period')
44+
45+ for period in period_obj.browse(self.cr, self.uid, form['periods']):
46+ aux.append(period.date_start)
47+ aux.append(period.date_stop)
48+ sorted(aux)
49+ return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
50
51 def get_informe_text(self, form):
52 """
53@@ -107,12 +111,12 @@
54 periods_str = None
55 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
56 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
57- if form['state'] in ['byperiod', 'all']:
58+ if form['filter'] in ['byperiod', 'all']:
59 period_ids = form['periods']
60 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
61
62 dates_str = None
63- if form['state'] in ['bydate', 'all']:
64+ if form['filter'] in ['bydate', 'all']:
65 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
66
67 return {'periods':periods_str, 'date':dates_str}
68@@ -184,13 +188,12 @@
69 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
70 else:
71 # Use all the open fiscal years
72- open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('state','=','draft')])
73+ open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('filter','=','draft')])
74 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
75
76 fy_balance = {}
77 for acc in account_obj.read(self.cr, self.uid, [x[0] for x in account_ids], ['balance'], ctx):
78 fy_balance[acc['id']] = acc['balance']
79-
80 #
81 # Calculate the FY Debit/Credit
82 # (from full fiscal year without opening or closing periods)
83@@ -204,12 +207,12 @@
84 # (from the selected period or all the non special periods in the fy)
85 #
86 ctx = self.context.copy()
87- ctx['state'] = form.get('state','all')
88+ ctx['filter'] = form.get('filter','all')
89 ctx['fiscalyear'] = fiscalyear.id
90 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id)])
91- if form['state'] in ['byperiod', 'all']:
92+ if form['filter'] in ['byperiod', 'all']:
93 ctx['periods'] = form['periods']
94- if form['state'] in ['bydate', 'all']:
95+ if form['filter'] in ['bydate', 'all']:
96 ctx['date_from'] = form['date_from']
97 ctx['date_to'] = form['date_to']
98
99
100=== modified file 'account_financial_report/report/account_balance_2_cols.py'
101--- account_financial_report/report/account_balance_2_cols.py 2012-01-02 22:36:00 +0000
102+++ account_financial_report/report/account_balance_2_cols.py 2012-01-20 23:38:23 +0000
103@@ -53,8 +53,8 @@
104 'lines': self.lines,
105 'get_fiscalyear_text': self.get_fiscalyear_text,
106 'get_periods_and_date_text': self.get_periods_and_date_text,
107- 'get_inf_text': self.get_informe_text,
108- 'get_month':self._get_month,
109+ 'get_informe_text': self.get_informe_text,
110+ 'get_month':self.get_month,
111 })
112 self.context = context
113
114@@ -78,27 +78,30 @@
115 """
116 inf_type = {
117 'bgen' : ' Balance General',
118- 'bcom' : ' Balance de Comprobacion',
119- 'edogp': 'Estado de Ganancias y Perdidas',
120- 'bdl': 'Libro Diario Legal',
121+ 'bcom' : ' Balance de Comprobacion',
122+ 'edogp': 'Estado de Ganancias y Perdidas'
123 }
124 return inf_type[form['inf_type']]
125
126- def _get_month(self, form):
127+ def get_month(self, form):
128 '''
129 return day, year and month
130 '''
131-
132- months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
133-
134- mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
135- ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
136- dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
137-
138- if form['inf_type']=='edogp':
139- return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)
140- else:
141- return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)
142+ if form['filter'] in ['bydate', 'all']:
143+ months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
144+ mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
145+ ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
146+ dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
147+ return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
148+ elif form['filter'] in ['byperiod', 'all']:
149+ aux=[]
150+ period_obj = self.pool.get('account.period')
151+
152+ for period in period_obj.browse(self.cr, self.uid, form['periods']):
153+ aux.append(period.date_start)
154+ aux.append(period.date_stop)
155+ sorted(aux)
156+ return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
157
158 def get_periods_and_date_text(self, form):
159 """
160@@ -108,14 +111,13 @@
161 periods_str = None
162 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
163 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
164- if form['state'] in ['byperiod', 'all']:
165+ if form['filter'] in ['byperiod', 'all']:
166 period_ids = form['periods']
167 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
168
169 dates_str = None
170- if form['state'] in ['bydate', 'all']:
171+ if form['filter'] in ['bydate', 'all']:
172 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
173-
174 return {'periods':periods_str, 'date':dates_str}
175
176
177@@ -125,14 +127,17 @@
178 (account info plus debit/credit/balance in the selected period
179 and the full year)
180 """
181+ tot_bin = 0.0
182 tot_deb = 0.0
183 tot_crd = 0.0
184+ tot_eje = 0.0
185 if not ids:
186 ids = self.ids
187 if not ids:
188 return []
189 if not done:
190 done = {}
191+
192 if form.has_key('account_list') and form['account_list']:
193 account_ids = form['account_list']
194 del form['account_list']
195@@ -143,7 +148,6 @@
196 period_obj = self.pool.get('account.period')
197 fiscalyear_obj = self.pool.get('account.fiscalyear')
198
199- # Get the fiscal year
200 fiscalyear = None
201 if form.get('fiscalyear'):
202 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])
203@@ -153,6 +157,7 @@
204 #
205 # Get the accounts
206 #
207+
208 def _get_children_and_consol(cr, uid, ids, level, context={}):
209 aa_obj = self.pool.get('account.account')
210 ids2=[]
211@@ -173,38 +178,42 @@
212 child_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form['display_account_level'] and form['display_account_level'] or 100,self.context)
213 if child_ids:
214 account_ids = child_ids
215+
216+ account_obj = self.pool.get('account.account')
217+ period_obj = self.pool.get('account.period')
218+ fiscalyear_obj = self.pool.get('account.fiscalyear')
219
220- #
221- # Calculate the period Debit/Credit
222- # (from the selected period or all the non special periods in the fy)
223- #
224+ #############################################################################
225+ # Calculate the period Debit/Credit #
226+ # (from the selected period or all the non special periods in the fy) #
227+ #############################################################################
228
229 ctx = self.context.copy()
230- ctx['state'] = form.get('state','all')
231+ ctx['filter'] = form.get('filter','all')
232 ctx['fiscalyear'] = fiscalyear.id
233- ctx['periods'] = form.get('periods')
234- if form['state'] in ['byperiod', 'all']:
235- date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
236- ctx['periods'] = ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
237- if form['state'] in ['bydate', 'all']:
238+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
239+ if form['filter'] in ['byperiod', 'all']:
240+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])
241+ if form['filter'] in ['bydate', 'all']:
242 ctx['date_from'] = form['date_from']
243 ctx['date_to'] = form['date_to']
244
245 accounts=[]
246+
247 val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx)
248 c = 0
249 for aa_id in account_ids:
250 new_acc = {
251- 'id' :val[c].id,
252- 'type' :val[c].type,
253- 'code' :val[c].code,
254- 'name' :val[c].name,
255- 'debit' :val[c].debit,
256- 'credit' :val[c].credit,
257- 'parent_id' :val[c].parent_id and val[c].parent_id.id,
258- 'level' :val[c].level,
259- 'label' :aa_id[1],
260- 'total' :aa_id[2],
261+ 'id' :val[c].id,
262+ 'type' :val[c].type,
263+ 'code' :val[c].code,
264+ 'name' :val[c].name,
265+ 'debit' :val[c].debit,
266+ 'credit' :val[c].credit,
267+ 'parent_id' :val[c].parent_id and val[c].parent_id.id,
268+ 'level' :val[c].level,
269+ 'label' :aa_id[1],
270+ 'total' :aa_id[2],
271 }
272 c += 1
273 accounts.append(new_acc)
274@@ -214,11 +223,38 @@
275 fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or []
276 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)])
277
278+ #############################################################################
279+ # Calculate the period initial Balance #
280+ # (fy balance minus the balance from the start of the selected period #
281+ # to the end of the year) #
282+ #############################################################################
283+
284+ ctx = self.context.copy()
285+ ctx['filter'] = form.get('filter','all')
286+ ctx['fiscalyear'] = fiscalyear.id
287+
288+ if form['filter'] in ['byperiod', 'all']:
289+ ctx['periods'] = form['periods']
290+ date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
291+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
292+ if not ctx['periods']:
293+ missing_period()
294+ elif form['filter'] in ['bydate']:
295+ ctx['date_from'] = fiscalyear.date_start
296+ ctx['date_to'] = form['date_from']
297+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])])
298+ elif form['filter'] == 'none':
299+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])
300+ date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
301+ ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])
302+
303+ period_balanceinit = {}
304+ for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx):
305+ period_balanceinit[acc['id']] = acc.balance
306
307 #
308 # Generate the report lines (checking each account)
309 #
310-
311 tot = {}
312 for account in accounts:
313 account_id = account['id']
314@@ -233,26 +269,31 @@
315 #
316 # Check if we need to include this level
317 #
318-
319 if not form['display_account_level'] or account['level'] <= form['display_account_level']:
320-
321 #
322 # Copy the account values
323 #
324-
325 res = {
326 'id' : account_id,
327 'type' : account['type'],
328 'code': account['code'],
329 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],
330 'level': account['level'],
331+ 'balanceinit': period_balanceinit[account_id],
332 'debit': account['debit'],
333 'credit': account['credit'],
334+ 'balance': period_balanceinit[account_id]+account['debit']-account['credit'],
335 'parent_id': account['parent_id'],
336 'bal_type': '',
337 'label': account['label'],
338 'total': account['total'],
339 }
340+ #
341+ # Round the values to zero if needed (-0.000001 ~= 0)
342+ #
343+
344+ if abs(res['balance']) < 0.5 * 10**-4:
345+ res['balance'] = 0.0
346
347 #
348 # Check whether we must include this line in the report or not
349@@ -260,30 +301,31 @@
350
351 if form['display_account'] == 'bal_mouvement' and account['parent_id']:
352 # Include accounts with movements
353- if abs(res['credit']-res['debit']) >= 0.5 * 10**-int(2) \
354- or abs(res['credit']) >= 0.5 * 10**-int(2) \
355- or abs(res['debit']) >= 0.5 * 10**-int(2):
356- result_acc.append(res)
357- elif form['display_account'] == 'bal_solde' and account['parent_id']:
358- # Include accounts with balance
359- if abs(res['credit']-res['debit']) >= 0.5 * 10**-int(2):
360- result_acc.append(res)
361- else:
362- # Include all account
363- result_acc.append(res)
364-
365+ if abs(res['balance']) >= 0.5 * 10**-int(2):
366+ result_acc.append(res)
367+ elif form['display_account'] == 'bal_solde' and account['parent_id']:
368+ # Include accounts with balance
369+ if abs(res['balance']) >= 0.5 * 10**-4:
370+ result_acc.append(res)
371+ else:
372+ # Include all accounts
373+ result_acc.append(res)
374 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
375 tot[res['id']] = True
376+ tot_bin += res['balanceinit']
377 tot_deb += res['debit']
378 tot_crd += res['credit']
379+ tot_eje += res['balance']
380
381 if form['tot_check']:
382 str_label = form['lab_str']
383 res2 = {
384 'type' : 'view',
385 'name': 'TOTAL %s'%(str_label),
386+ 'balanceinit': tot_bin,
387 'debit': tot_deb,
388 'credit': tot_crd,
389+ 'balance': tot_eje,
390 'label': False,
391 'total': True,
392 }
393
394=== modified file 'account_financial_report/report/account_balance_4_cols.py'
395--- account_financial_report/report/account_balance_4_cols.py 2012-01-02 22:27:49 +0000
396+++ account_financial_report/report/account_balance_4_cols.py 2012-01-20 23:38:23 +0000
397@@ -53,8 +53,8 @@
398 'lines': self.lines,
399 'get_fiscalyear_text': self.get_fiscalyear_text,
400 'get_periods_and_date_text': self.get_periods_and_date_text,
401- 'get_inf_text': self.get_informe_text,
402- 'get_month':self._get_month,
403+ 'get_informe_text': self.get_informe_text,
404+ 'get_month':self.get_month,
405 })
406 self.context = context
407
408@@ -78,27 +78,30 @@
409 """
410 inf_type = {
411 'bgen' : ' Balance General',
412- 'bcom' : ' Balance de Comprobacion',
413- 'edogp': 'Estado de Ganancias y Perdidas',
414- 'bml': 'Libro Mayor Legal',
415+ 'bcom' : ' Balance de Comprobacion',
416+ 'edogp': 'Estado de Ganancias y Perdidas'
417 }
418 return inf_type[form['inf_type']]
419
420- def _get_month(self, form):
421+ def get_month(self, form):
422 '''
423 return day, year and month
424 '''
425-
426- months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
427-
428- mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
429- ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
430- dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
431-
432- if form['inf_type']=='edogp':
433- return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)
434- else:
435- return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)
436+ if form['filter'] in ['bydate', 'all']:
437+ months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
438+ mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
439+ ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
440+ dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
441+ return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
442+ elif form['filter'] in ['byperiod', 'all']:
443+ aux=[]
444+ period_obj = self.pool.get('account.period')
445+
446+ for period in period_obj.browse(self.cr, self.uid, form['periods']):
447+ aux.append(period.date_start)
448+ aux.append(period.date_stop)
449+ sorted(aux)
450+ return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
451
452 def get_periods_and_date_text(self, form):
453 """
454@@ -108,12 +111,12 @@
455 periods_str = None
456 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
457 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
458- if form['state'] in ['byperiod', 'all']:
459+ if form['filter'] in ['byperiod', 'all']:
460 period_ids = form['periods']
461 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
462
463 dates_str = None
464- if form['state'] in ['bydate', 'all']:
465+ if form['filter'] in ['bydate', 'all']:
466 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
467 return {'periods':periods_str, 'date':dates_str}
468
469@@ -186,12 +189,12 @@
470 #############################################################################
471
472 ctx = self.context.copy()
473- ctx['state'] = form.get('state','all')
474+ ctx['filter'] = form.get('filter','all')
475 ctx['fiscalyear'] = fiscalyear.id
476 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
477- if form['state'] in ['byperiod', 'all']:
478+ if form['filter'] in ['byperiod', 'all']:
479 ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])
480- if form['state'] in ['bydate', 'all']:
481+ if form['filter'] in ['bydate', 'all']:
482 ctx['date_from'] = form['date_from']
483 ctx['date_to'] = form['date_to']
484
485@@ -227,20 +230,20 @@
486 #############################################################################
487
488 ctx = self.context.copy()
489- ctx['state'] = form.get('state','all')
490+ ctx['filter'] = form.get('filter','all')
491 ctx['fiscalyear'] = fiscalyear.id
492
493- if form['state'] in ['byperiod', 'all']:
494+ if form['filter'] in ['byperiod', 'all']:
495 ctx['periods'] = form['periods']
496 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
497 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
498 if not ctx['periods']:
499 missing_period()
500- elif form['state'] in ['bydate']:
501+ elif form['filter'] in ['bydate']:
502 ctx['date_from'] = fiscalyear.date_start
503 ctx['date_to'] = form['date_from']
504 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])])
505- elif form['state'] == 'none':
506+ elif form['filter'] == 'none':
507 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])
508 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
509 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])
510
511=== modified file 'account_financial_report/report/balance_full.rml'
512--- account_financial_report/report/balance_full.rml 2012-01-02 22:27:49 +0000
513+++ account_financial_report/report/balance_full.rml 2012-01-20 23:38:23 +0000
514@@ -5,37 +5,26 @@
515 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
516 <pageGraphics>
517 <setFont name="Helvetica" size="9"/>
518-
519-<!--
520- <image x="1.0cm" y="25.0cm" height="2.5cm" width="9.6cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
521- <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
522--->
523-
524 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
525 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
526 <tr>
527 <td><para style="TOP_TITLE"></para></td>
528- <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>
529- </tr>
530- <tr>
531- <td><para style="TOP_TITLE"></para></td>
532- <td><para style="TITLE_CENTER">[[ (company.partner_id.vat and ('RIF: %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or removeParentNode('para')) ]]</para></td>
533- </tr>
534- <tr>
535- <td><para style="TOP_TITLE"></para></td>
536- <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
537+ <td><para style="TITLE_CENTER_NAME">
538+ <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
539+ <font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
540+ </para></td>
541+ </tr>
542+ <tr>
543+ <td><para style="TOP_TITLE"></para></td>
544+ <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
545 </tr>
546 <tr>
547 <td><para style="TOP_TITLE"></para></td>
548 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
549 </tr>
550- <tr>
551- <td><para style="TOP_TITLE"></para></td>
552- <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
553- </tr>
554 </blockTable>
555 </place>
556- <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
557+ <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
558 </pageGraphics>
559
560 </pageTemplate>
561@@ -108,7 +97,7 @@
562 <para style="TITLES">Cuenta</para>
563 </td>
564 <td>
565- <para style="TITLE_LEFT_ALIGN"></para>
566+ <para style="TITLE_LEFT_ALIGN">Balance</para>
567 </td>
568 </tr>
569 <tr>
570@@ -127,7 +116,7 @@
571 <td>
572 <para style="TITLE_LEFT_ALIGN">
573 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
574- <font>[[ (a['total']==True) and formatLang(a['balance']) or '']]</font>
575+ <font>[[(a['total']==True) and formatLang(a['balance']) or '']]</font>
576 </para>
577 </td>
578 </tr>
579
580=== modified file 'account_financial_report/report/balance_full_2_cols.rml'
581--- account_financial_report/report/balance_full_2_cols.rml 2012-01-02 22:27:49 +0000
582+++ account_financial_report/report/balance_full_2_cols.rml 2012-01-20 23:38:23 +0000
583@@ -5,37 +5,26 @@
584 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
585 <pageGraphics>
586 <setFont name="Helvetica" size="9"/>
587-
588-<!--
589- <image x="1.0cm" y="25.0cm" height="2.5cm" width="9.6cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
590- <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
591--->
592-
593 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
594 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
595 <tr>
596 <td><para style="TOP_TITLE"></para></td>
597- <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>
598- </tr>
599- <tr>
600- <td><para style="TOP_TITLE"></para></td>
601- <td><para style="TITLE_CENTER">[[ (company.partner_id.vat and ('RIF: %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or removeParentNode('para')) ]]</para></td>
602- </tr>
603- <tr>
604- <td><para style="TOP_TITLE"></para></td>
605- <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
606+ <td><para style="TITLE_CENTER_NAME">
607+ <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
608+ <font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
609+ </para></td>
610+ </tr>
611+ <tr>
612+ <td><para style="TOP_TITLE"></para></td>
613+ <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
614 </tr>
615 <tr>
616 <td><para style="TOP_TITLE"></para></td>
617 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
618 </tr>
619- <tr>
620- <td><para style="TOP_TITLE"></para></td>
621- <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
622- </tr>
623 </blockTable>
624 </place>
625- <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
626+ <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
627 </pageGraphics>
628
629 </pageTemplate>
630@@ -43,7 +32,7 @@
631 <stylesheet>
632 <blockTableStyle id="TITLE">
633 <blockValign value="TOP"/>
634- </blockTableStyle>
635+ </blockTableStyle>
636 <blockTableStyle id="BODY">
637 <blockValign value="TOP"/>
638 <blockAlignment value="RIGHT"/>
639@@ -75,32 +64,20 @@
640 alignment="RIGHT"
641 spaceBefore="0.0"
642 spaceAfter="0.0"/>
643- <paraStyle
644- name="TOP_TITLE"
645- fontName="Helvetica-Bold"
646- fontSize="9"
647- leftIndent="0.0"
648- alignment="LEFT"/>
649- <paraStyle name="TITLES"
650- fontName="Helvetica-Bold"
651- fontSize="8.0"
652- leading="10"
653- alignment="LEFT"
654- spaceBefore="0.0"
655- spaceAfter="0.0"/>
656+ <paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="9" leftIndent="0.0" alignment="LEFT"/>
657+ <paraStyle name="TITLES" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
658 <paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="9" leading="10" leftIndent="0.0" alignment="CENTER"/>
659 <paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
660 <paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>
661-
662 </stylesheet>
663 <images/>
664 <story>
665 <para>[[setLang(user.context_lang)]]</para>
666- <blockTable colWidths="2.5cm,11.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">
667+ <blockTable colWidths="2.5cm,9.5cm,3.5cm,3.5cm" style="BODY" repeatRows="1">
668 <tr noRowsplits="1">
669 <td>
670 <para style="TITLE_LEFT_ALIGN">
671- <font>Código</font>
672+ <font>Código</font>
673 </para>
674 </td>
675 <td>
676@@ -119,7 +96,6 @@
677 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
678 <i>[[a['label']==True and a['code'] or '' ]]</i>
679 </para>
680-
681 </td>
682 <td>
683 <para style="TITLES">
684
685=== modified file 'account_financial_report/report/balance_full_4_cols.rml'
686--- account_financial_report/report/balance_full_4_cols.rml 2012-01-02 22:27:49 +0000
687+++ account_financial_report/report/balance_full_4_cols.rml 2012-01-20 23:38:23 +0000
688@@ -2,7 +2,7 @@
689 <document filename="test.pdf">
690 <template pageSize="(21.59cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
691 <pageTemplate id="first">
692- <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
693+ <frame id="first" x1="0.5cm" y1="1.0cm" width="20.5cm" height="23cm"/>
694 <pageGraphics>
695 <setFont name="Helvetica" size="9"/>
696
697@@ -15,27 +15,22 @@
698 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
699 <tr>
700 <td><para style="TOP_TITLE"></para></td>
701- <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>
702- </tr>
703- <tr>
704- <td><para style="TOP_TITLE"></para></td>
705- <td><para style="TITLE_CENTER">[[ (company.partner_id.vat and ('RIF: %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or removeParentNode('para')) ]]</para></td>
706- </tr>
707- <tr>
708- <td><para style="TOP_TITLE"></para></td>
709- <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
710+ <td><para style="TITLE_CENTER_NAME">
711+ <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
712+ <font>[[ company.partner_id.vat and ('- %s-%s-%s'%(company.partner_id.vat[2:3],company.partner_id.vat[3:11],company.partner_id.vat[11:12])) or '' ]]</font>
713+ </para></td>
714+ </tr>
715+ <tr>
716+ <td><para style="TOP_TITLE"></para></td>
717+ <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
718 </tr>
719 <tr>
720 <td><para style="TOP_TITLE"></para></td>
721 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
722 </tr>
723- <tr>
724- <td><para style="TOP_TITLE"></para></td>
725- <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
726- </tr>
727 </blockTable>
728 </place>
729- <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
730+ <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
731 </pageGraphics>
732
733 </pageTemplate>
734@@ -84,7 +79,7 @@
735 <images/>
736 <story>
737 <para>[[setLang(user.context_lang)]]</para>
738- <blockTable colWidths="2.5cm,6.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">
739+ <blockTable colWidths="2.5cm,6.5cm,2.5cm,3.5cm,3.5cm,2.5cm" style="BODY" repeatRows="1">
740 <tr noRowsplits="1">
741 <td>
742 <para style="TITLE_LEFT_ALIGN">
743
744=== modified file 'account_financial_report/wizard/account_report_wizard.xml'
745--- account_financial_report/wizard/account_report_wizard.xml 2012-01-02 21:37:32 +0000
746+++ account_financial_report/wizard/account_report_wizard.xml 2012-01-20 23:38:23 +0000
747@@ -22,16 +22,16 @@
748 <separator string="Period" colspan="4"/>
749 <field name="fiscalyear"/>
750 <newline/>
751- <field name="state" required="True"/>
752+ <field name="filter" required="True"/>
753 <newline/>
754
755- <group attrs="{'invisible':[('state','=','none')]}" colspan="4">
756- <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
757+ <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
758+ <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
759 <separator string="Date Filter" colspan="4"/>
760 <field name="date_from"/>
761 <field name="date_to"/>
762 </group>
763- <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
764+ <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
765 <separator string="Filter on Periods" colspan="4"/>
766 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
767 </group>
768@@ -87,15 +87,15 @@
769 <separator string="Period" colspan="4"/>
770 <field name="fiscalyear"/>
771 <newline/>
772- <field name="state" required="True"/>
773+ <field name="filter" required="True"/>
774 <newline/>
775- <group attrs="{'invisible':[('state','=','none')]}" colspan="4">
776- <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
777+ <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
778+ <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
779 <separator string="Date Filter" colspan="4"/>
780 <field name="date_from"/>
781 <field name="date_to"/>
782 </group>
783- <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
784+ <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
785 <separator string="Filter on Periods" colspan="4"/>
786 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
787 </group>
788@@ -149,15 +149,15 @@
789 <separator string="Period" colspan="4"/>
790 <field name="fiscalyear"/>
791 <newline/>
792- <field name="state" required="True"/>
793+ <field name="filter" required="True"/>
794 <newline/>
795- <group attrs="{'invisible':[('state','=','none')]}" colspan="4">
796- <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
797+ <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
798+ <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
799 <separator string="Date Filter" colspan="4"/>
800 <field name="date_from"/>
801 <field name="date_to"/>
802 </group>
803- <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
804+ <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
805 <separator string="Filter on Periods" colspan="4"/>
806 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
807 </group>
808
809=== modified file 'account_financial_report/wizard/wizard_account_balance_2_report.py'
810--- account_financial_report/wizard/wizard_account_balance_2_report.py 2012-01-02 22:27:49 +0000
811+++ account_financial_report/wizard/wizard_account_balance_2_report.py 2012-01-20 23:38:23 +0000
812@@ -29,36 +29,47 @@
813 from osv import osv,fields
814 import pooler
815 import time
816+
817 class wizard_account_balance_gene_2(osv.osv_memory):
818 _name = "wizard.report.account.balance.gene.2"
819
820 _columns = {
821 'company_id': fields.many2one('res.company','Company',required=True),
822 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
823- 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
824+ 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
825 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
826 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
827- 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),
828+ 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
829 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
830- 'date_from': fields.date('Start date',required=True),
831- 'date_to': fields.date('End date',required=True),
832+ 'date_from': fields.date('Start date'),
833+ 'date_to': fields.date('End date'),
834 'tot_check': fields.boolean('Show Total'),
835 'lab_str': fields.char('Description', size= 128),
836- 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bdl','Libro Diario Legal')],'Tipo Informe',required=True),
837+ 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
838+ #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
839 }
840
841 _defaults = {
842 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
843 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
844- 'state': lambda *a:'byperiod',
845+ 'filter': lambda *a:'byperiod',
846 'display_account_level': lambda *a: 0,
847 'inf_type': lambda *a:'bcom',
848 'company_id': lambda *a: 1,
849- 'fiscalyear': lambda *a: 1,
850- 'display_account': lambda *a:'bal_mouvement',
851-
852+ 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
853+ 'display_account': lambda *a:'con_movimiento',
854 }
855-
856+
857+ def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
858+ if context is None:
859+ context = {}
860+ res = {}
861+ if filters in ("bydate","all"):
862+ fisy = self.pool.get("account.fiscalyear")
863+ fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
864+ res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
865+ return res
866+
867 def _get_defaults(self, cr, uid, data, context=None):
868 if context is None:
869 context = {}
870@@ -73,40 +84,65 @@
871 data['form']['context'] = context
872 return data['form']
873
874-
875 def _check_state(self, cr, uid, data, context=None):
876 if context is None:
877 context = {}
878- if data['form']['state'] == 'bydate':
879+ if data['form']['filter'] == 'bydate':
880 self._check_date(cr, uid, data, context)
881 return data['form']
882
883-
884 def _check_date(self, cr, uid, data, context=None):
885 if context is None:
886 context = {}
887+
888+ if data['form']['date_from'] > data['form']['date_to']:
889+ raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
890+
891 sql = """SELECT f.id, f.date_start, f.date_stop
892 FROM account_fiscalyear f
893- WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
894+ WHERE '%s' = f.id """%(data['form']['fiscalyear'])
895 cr.execute(sql)
896 res = cr.dictfetchall()
897+
898 if res:
899- if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
900- raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))
901+ if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
902+ raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
903 else:
904 return 'report'
905 else:
906- raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
907+ raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
908
909 def print_report(self, cr, uid, ids,data, context=None):
910 if context is None:
911 context = {}
912+
913 data = {}
914 data['ids'] = context.get('active_ids', [])
915 data['model'] = context.get('active_model', 'ir.ui.menu')
916 data['form'] = self.read(cr, uid, ids[0])
917+
918+ if data['form']['filter'] == 'byperiod':
919+ del data['form']['date_from']
920+ del data['form']['date_to']
921+ elif data['form']['filter'] == 'bydate':
922+ self._check_date(cr, uid, data)
923+ del data['form']['periods']
924+ elif data['form']['filter'] == 'none':
925+ del data['form']['date_from']
926+ del data['form']['date_to']
927+ del data['form']['periods']
928+ else:
929+ self._check_date(cr, uid, data)
930+ lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
931+ sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
932+ from account_period p
933+ where p.id in %s"""%lis2
934+ cr.execute(sqlmm)
935+ minmax = cr.dictfetchall()
936+ if minmax:
937+ if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
938+ raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
939+
940 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene.2', 'datas': data}
941
942 wizard_account_balance_gene_2()
943-
944-
945
946=== modified file 'account_financial_report/wizard/wizard_account_balance_4_report.py'
947--- account_financial_report/wizard/wizard_account_balance_4_report.py 2012-01-02 22:27:49 +0000
948+++ account_financial_report/wizard/wizard_account_balance_4_report.py 2012-01-20 23:38:23 +0000
949@@ -1,37 +1,75 @@
950 # -*- encoding: utf-8 -*-
951+###########################################################################
952+# Module Writen to OpenERP, Open Source Management Solution
953+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
954+# All Rights Reserved
955+###############Credits######################################################
956+# Coded by: Humberto Arocha humberto@openerp.com.ve
957+# Angelica Barrios angelicaisabelb@gmail.com
958+# Jordi Esteve <jesteve@zikzakmedia.com>
959+# Javier Duran <javieredm@gmail.com>
960+# Planified by: Humberto Arocha
961+# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com
962+# Audited by: Humberto Arocha humberto@openerp.com.ve
963+#############################################################################
964+# This program is free software: you can redistribute it and/or modify
965+# it under the terms of the GNU General Public License as published by
966+# the Free Software Foundation, either version 3 of the License, or
967+# (at your option) any later version.
968+#
969+# This program is distributed in the hope that it will be useful,
970+# but WITHOUT ANY WARRANTY; without even the implied warranty of
971+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
972+# GNU General Public License for more details.
973+#
974+# You should have received a copy of the GNU General Public License
975+# along with this program. If not, see <http://www.gnu.org/licenses/>.
976+##############################################################################
977+
978 from osv import osv,fields
979 import pooler
980 import time
981+
982 class wizard_report(osv.osv_memory):
983 _name = "wizard.report"
984
985 _columns = {
986 'company_id': fields.many2one('res.company','Company',required=True),
987 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
988- 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
989+ 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
990 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
991 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
992- 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),
993+ 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
994 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
995- 'date_from': fields.date('Start date',required=True),
996- 'date_to': fields.date('End date',required=True),
997+ 'date_from': fields.date('Start date'),
998+ 'date_to': fields.date('End date'),
999 'tot_check': fields.boolean('Show Total'),
1000 'lab_str': fields.char('Description', size= 128),
1001- 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True),
1002+ 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
1003+ #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
1004 }
1005
1006 _defaults = {
1007 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
1008 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
1009- 'state': lambda *a:'byperiod',
1010+ 'filter': lambda *a:'byperiod',
1011 'display_account_level': lambda *a: 0,
1012 'inf_type': lambda *a:'bcom',
1013 'company_id': lambda *a: 1,
1014- 'fiscalyear': lambda *a: 1,
1015- 'display_account': lambda *a:'bal_mouvement',
1016-
1017+ 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
1018+ 'display_account': lambda *a:'con_movimiento',
1019 }
1020-
1021+
1022+ def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
1023+ if context is None:
1024+ context = {}
1025+ res = {}
1026+ if filters in ("bydate","all"):
1027+ fisy = self.pool.get("account.fiscalyear")
1028+ fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
1029+ res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
1030+ return res
1031+
1032 def _get_defaults(self, cr, uid, data, context=None):
1033 if context is None:
1034 context = {}
1035@@ -46,38 +84,65 @@
1036 data['form']['context'] = context
1037 return data['form']
1038
1039-
1040 def _check_state(self, cr, uid, data, context=None):
1041 if context is None:
1042 context = {}
1043- if data['form']['state'] == 'bydate':
1044+ if data['form']['filter'] == 'bydate':
1045 self._check_date(cr, uid, data, context)
1046 return data['form']
1047
1048-
1049 def _check_date(self, cr, uid, data, context=None):
1050 if context is None:
1051 context = {}
1052+
1053+ if data['form']['date_from'] > data['form']['date_to']:
1054+ raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
1055+
1056 sql = """SELECT f.id, f.date_start, f.date_stop
1057 FROM account_fiscalyear f
1058- WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
1059+ WHERE '%s' = f.id """%(data['form']['fiscalyear'])
1060 cr.execute(sql)
1061 res = cr.dictfetchall()
1062+
1063 if res:
1064- if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
1065- raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))
1066+ if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
1067+ raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
1068 else:
1069 return 'report'
1070 else:
1071- raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
1072+ raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
1073
1074 def print_report(self, cr, uid, ids,data, context=None):
1075 if context is None:
1076 context = {}
1077+
1078 data = {}
1079 data['ids'] = context.get('active_ids', [])
1080 data['model'] = context.get('active_model', 'ir.ui.menu')
1081 data['form'] = self.read(cr, uid, ids[0])
1082+
1083+ if data['form']['filter'] == 'byperiod':
1084+ del data['form']['date_from']
1085+ del data['form']['date_to']
1086+ elif data['form']['filter'] == 'bydate':
1087+ self._check_date(cr, uid, data)
1088+ del data['form']['periods']
1089+ elif data['form']['filter'] == 'none':
1090+ del data['form']['date_from']
1091+ del data['form']['date_to']
1092+ del data['form']['periods']
1093+ else:
1094+ self._check_date(cr, uid, data)
1095+ lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
1096+ sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
1097+ from account_period p
1098+ where p.id in %s"""%lis2
1099+ cr.execute(sqlmm)
1100+ minmax = cr.dictfetchall()
1101+ if minmax:
1102+ if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
1103+ raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
1104+
1105 return {'type': 'ir.actions.report.xml', 'report_name': 'wizard.report.reporte', 'datas': data}
1106-
1107+
1108 wizard_report()
1109
1110=== modified file 'account_financial_report/wizard/wizard_account_balance_report.py'
1111--- account_financial_report/wizard/wizard_account_balance_report.py 2012-01-02 21:37:32 +0000
1112+++ account_financial_report/wizard/wizard_account_balance_report.py 2012-01-20 23:38:23 +0000
1113@@ -26,40 +26,50 @@
1114 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1115 ##############################################################################
1116
1117-
1118 from osv import osv,fields
1119 import pooler
1120 import time
1121+
1122 class wizard_account_balance_gene(osv.osv_memory):
1123 _name = "wizard.report.account.balance.gene"
1124
1125 _columns = {
1126 'company_id': fields.many2one('res.company','Company',required=True),
1127 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
1128- 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
1129+ 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
1130 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
1131 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
1132- 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),
1133+ 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
1134 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
1135- 'date_from': fields.date('Start date',required=True),
1136- 'date_to': fields.date('End date',required=True),
1137+ 'date_from': fields.date('Start date'),
1138+ 'date_to': fields.date('End date'),
1139 'tot_check': fields.boolean('Show Total'),
1140 'lab_str': fields.char('Description', size= 128),
1141 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
1142+ #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
1143 }
1144
1145 _defaults = {
1146 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
1147 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
1148- 'state': lambda *a:'byperiod',
1149+ 'filter': lambda *a:'byperiod',
1150 'display_account_level': lambda *a: 0,
1151 'inf_type': lambda *a:'bcom',
1152 'company_id': lambda *a: 1,
1153- 'fiscalyear': lambda *a: 1,
1154- 'display_account': lambda *a:'bal_mouvement',
1155-
1156+ 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
1157+ 'display_account': lambda *a:'con_movimiento',
1158 }
1159-
1160+
1161+ def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
1162+ if context is None:
1163+ context = {}
1164+ res = {}
1165+ if filters in ("bydate","all"):
1166+ fisy = self.pool.get("account.fiscalyear")
1167+ fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
1168+ res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
1169+ return res
1170+
1171 def _get_defaults(self, cr, uid, data, context=None):
1172 if context is None:
1173 context = {}
1174@@ -74,39 +84,65 @@
1175 data['form']['context'] = context
1176 return data['form']
1177
1178-
1179 def _check_state(self, cr, uid, data, context=None):
1180 if context is None:
1181 context = {}
1182- if data['form']['state'] == 'bydate':
1183+ if data['form']['filter'] == 'bydate':
1184 self._check_date(cr, uid, data, context)
1185 return data['form']
1186
1187-
1188 def _check_date(self, cr, uid, data, context=None):
1189 if context is None:
1190 context = {}
1191+
1192+ if data['form']['date_from'] > data['form']['date_to']:
1193+ raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
1194+
1195 sql = """SELECT f.id, f.date_start, f.date_stop
1196 FROM account_fiscalyear f
1197- WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
1198+ WHERE '%s' = f.id """%(data['form']['fiscalyear'])
1199 cr.execute(sql)
1200 res = cr.dictfetchall()
1201+
1202 if res:
1203- if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
1204- raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))
1205+ if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
1206+ raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
1207 else:
1208 return 'report'
1209 else:
1210- raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
1211+ raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
1212
1213 def print_report(self, cr, uid, ids,data, context=None):
1214 if context is None:
1215 context = {}
1216+
1217 data = {}
1218 data['ids'] = context.get('active_ids', [])
1219 data['model'] = context.get('active_model', 'ir.ui.menu')
1220 data['form'] = self.read(cr, uid, ids[0])
1221+
1222+ if data['form']['filter'] == 'byperiod':
1223+ del data['form']['date_from']
1224+ del data['form']['date_to']
1225+ elif data['form']['filter'] == 'bydate':
1226+ self._check_date(cr, uid, data)
1227+ del data['form']['periods']
1228+ elif data['form']['filter'] == 'none':
1229+ del data['form']['date_from']
1230+ del data['form']['date_to']
1231+ del data['form']['periods']
1232+ else:
1233+ self._check_date(cr, uid, data)
1234+ lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
1235+ sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
1236+ from account_period p
1237+ where p.id in %s"""%lis2
1238+ cr.execute(sqlmm)
1239+ minmax = cr.dictfetchall()
1240+ if minmax:
1241+ if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
1242+ raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
1243+
1244 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene', 'datas': data}
1245
1246 wizard_account_balance_gene()
1247-

Subscribers

People subscribed via source and target branches

to all changes: