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
=== modified file 'account_financial_report/report/account_balance.py'
--- account_financial_report/report/account_balance.py 2012-01-02 22:27:49 +0000
+++ account_financial_report/report/account_balance.py 2012-01-20 23:38:23 +0000
@@ -53,8 +53,8 @@
53 'lines': self.lines,53 'lines': self.lines,
54 'get_fiscalyear_text': self.get_fiscalyear_text,54 'get_fiscalyear_text': self.get_fiscalyear_text,
55 'get_periods_and_date_text': self.get_periods_and_date_text,55 'get_periods_and_date_text': self.get_periods_and_date_text,
56 'get_inf_text': self.get_informe_text,56 'get_informe_text': self.get_informe_text,
57 'get_month':self._get_month,57 'get_month':self.get_month,
58 })58 })
59 self.context = context59 self.context = context
6060
@@ -72,21 +72,25 @@
72 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))72 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
73 return "%s*" % (fiscalyear.name or fiscalyear.code)73 return "%s*" % (fiscalyear.name or fiscalyear.code)
74 74
75 def _get_month(self, form):75 def get_month(self, form):
76 '''76 '''
77 return day, year and month77 return day, year and month
78 '''78 '''
7979 if form['filter'] in ['bydate', 'all']:
80 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]80 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
8181 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
82 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]82 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
83 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]83 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
84 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]84 return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
8585 elif form['filter'] in ['byperiod', 'all']:
86 if form['inf_type']=='edogp':86 aux=[]
87 return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)87 period_obj = self.pool.get('account.period')
88 else:88
89 return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)89 for period in period_obj.browse(self.cr, self.uid, form['periods']):
90 aux.append(period.date_start)
91 aux.append(period.date_stop)
92 sorted(aux)
93 return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
9094
91 def get_informe_text(self, form):95 def get_informe_text(self, form):
92 """96 """
@@ -107,12 +111,12 @@
107 periods_str = None111 periods_str = None
108 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)112 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
109 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])113 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
110 if form['state'] in ['byperiod', 'all']:114 if form['filter'] in ['byperiod', 'all']:
111 period_ids = form['periods']115 period_ids = form['periods']
112 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])116 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
113117
114 dates_str = None118 dates_str = None
115 if form['state'] in ['bydate', 'all']:119 if form['filter'] in ['bydate', 'all']:
116 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '120 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
117121
118 return {'periods':periods_str, 'date':dates_str}122 return {'periods':periods_str, 'date':dates_str}
@@ -184,13 +188,12 @@
184 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])188 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
185 else:189 else:
186 # Use all the open fiscal years190 # Use all the open fiscal years
187 open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('state','=','draft')])191 open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('filter','=','draft')])
188 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])192 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
189193
190 fy_balance = {}194 fy_balance = {}
191 for acc in account_obj.read(self.cr, self.uid, [x[0] for x in account_ids], ['balance'], ctx):195 for acc in account_obj.read(self.cr, self.uid, [x[0] for x in account_ids], ['balance'], ctx):
192 fy_balance[acc['id']] = acc['balance']196 fy_balance[acc['id']] = acc['balance']
193
194 #197 #
195 # Calculate the FY Debit/Credit198 # Calculate the FY Debit/Credit
196 # (from full fiscal year without opening or closing periods)199 # (from full fiscal year without opening or closing periods)
@@ -204,12 +207,12 @@
204 # (from the selected period or all the non special periods in the fy)207 # (from the selected period or all the non special periods in the fy)
205 #208 #
206 ctx = self.context.copy()209 ctx = self.context.copy()
207 ctx['state'] = form.get('state','all')210 ctx['filter'] = form.get('filter','all')
208 ctx['fiscalyear'] = fiscalyear.id211 ctx['fiscalyear'] = fiscalyear.id
209 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id)])212 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id)])
210 if form['state'] in ['byperiod', 'all']:213 if form['filter'] in ['byperiod', 'all']:
211 ctx['periods'] = form['periods']214 ctx['periods'] = form['periods']
212 if form['state'] in ['bydate', 'all']:215 if form['filter'] in ['bydate', 'all']:
213 ctx['date_from'] = form['date_from']216 ctx['date_from'] = form['date_from']
214 ctx['date_to'] = form['date_to']217 ctx['date_to'] = form['date_to']
215218
216219
=== modified file 'account_financial_report/report/account_balance_2_cols.py'
--- account_financial_report/report/account_balance_2_cols.py 2012-01-02 22:36:00 +0000
+++ account_financial_report/report/account_balance_2_cols.py 2012-01-20 23:38:23 +0000
@@ -53,8 +53,8 @@
53 'lines': self.lines,53 'lines': self.lines,
54 'get_fiscalyear_text': self.get_fiscalyear_text,54 'get_fiscalyear_text': self.get_fiscalyear_text,
55 'get_periods_and_date_text': self.get_periods_and_date_text,55 'get_periods_and_date_text': self.get_periods_and_date_text,
56 'get_inf_text': self.get_informe_text,56 'get_informe_text': self.get_informe_text,
57 'get_month':self._get_month,57 'get_month':self.get_month,
58 })58 })
59 self.context = context59 self.context = context
6060
@@ -78,27 +78,30 @@
78 """78 """
79 inf_type = {79 inf_type = {
80 'bgen' : ' Balance General',80 'bgen' : ' Balance General',
81 'bcom' : ' Balance de Comprobacion',81 'bcom' : ' Balance de Comprobacion',
82 'edogp': 'Estado de Ganancias y Perdidas',82 'edogp': 'Estado de Ganancias y Perdidas'
83 'bdl': 'Libro Diario Legal',
84 }83 }
85 return inf_type[form['inf_type']]84 return inf_type[form['inf_type']]
8685
87 def _get_month(self, form):86 def get_month(self, form):
88 '''87 '''
89 return day, year and month88 return day, year and month
90 '''89 '''
9190 if form['filter'] in ['bydate', 'all']:
92 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]91 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
9392 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
94 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]93 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
95 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]94 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
96 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]95 return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
9796 elif form['filter'] in ['byperiod', 'all']:
98 if form['inf_type']=='edogp':97 aux=[]
99 return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)98 period_obj = self.pool.get('account.period')
100 else:99
101 return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)100 for period in period_obj.browse(self.cr, self.uid, form['periods']):
101 aux.append(period.date_start)
102 aux.append(period.date_stop)
103 sorted(aux)
104 return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
102105
103 def get_periods_and_date_text(self, form):106 def get_periods_and_date_text(self, form):
104 """107 """
@@ -108,14 +111,13 @@
108 periods_str = None111 periods_str = None
109 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)112 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
110 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])113 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
111 if form['state'] in ['byperiod', 'all']:114 if form['filter'] in ['byperiod', 'all']:
112 period_ids = form['periods']115 period_ids = form['periods']
113 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])116 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
114117
115 dates_str = None118 dates_str = None
116 if form['state'] in ['bydate', 'all']:119 if form['filter'] in ['bydate', 'all']:
117 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '120 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
118
119 return {'periods':periods_str, 'date':dates_str}121 return {'periods':periods_str, 'date':dates_str}
120122
121123
@@ -125,14 +127,17 @@
125 (account info plus debit/credit/balance in the selected period127 (account info plus debit/credit/balance in the selected period
126 and the full year)128 and the full year)
127 """129 """
130 tot_bin = 0.0
128 tot_deb = 0.0131 tot_deb = 0.0
129 tot_crd = 0.0132 tot_crd = 0.0
133 tot_eje = 0.0
130 if not ids:134 if not ids:
131 ids = self.ids135 ids = self.ids
132 if not ids:136 if not ids:
133 return []137 return []
134 if not done:138 if not done:
135 done = {}139 done = {}
140
136 if form.has_key('account_list') and form['account_list']:141 if form.has_key('account_list') and form['account_list']:
137 account_ids = form['account_list']142 account_ids = form['account_list']
138 del form['account_list']143 del form['account_list']
@@ -143,7 +148,6 @@
143 period_obj = self.pool.get('account.period')148 period_obj = self.pool.get('account.period')
144 fiscalyear_obj = self.pool.get('account.fiscalyear')149 fiscalyear_obj = self.pool.get('account.fiscalyear')
145150
146 # Get the fiscal year
147 fiscalyear = None151 fiscalyear = None
148 if form.get('fiscalyear'):152 if form.get('fiscalyear'):
149 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])153 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'])
@@ -153,6 +157,7 @@
153 #157 #
154 # Get the accounts158 # Get the accounts
155 #159 #
160
156 def _get_children_and_consol(cr, uid, ids, level, context={}):161 def _get_children_and_consol(cr, uid, ids, level, context={}):
157 aa_obj = self.pool.get('account.account')162 aa_obj = self.pool.get('account.account')
158 ids2=[]163 ids2=[]
@@ -173,38 +178,42 @@
173 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)178 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)
174 if child_ids:179 if child_ids:
175 account_ids = child_ids180 account_ids = child_ids
181
182 account_obj = self.pool.get('account.account')
183 period_obj = self.pool.get('account.period')
184 fiscalyear_obj = self.pool.get('account.fiscalyear')
176185
177 #186 #############################################################################
178 # Calculate the period Debit/Credit187 # Calculate the period Debit/Credit #
179 # (from the selected period or all the non special periods in the fy)188 # (from the selected period or all the non special periods in the fy) #
180 #189 #############################################################################
181190
182 ctx = self.context.copy()191 ctx = self.context.copy()
183 ctx['state'] = form.get('state','all')192 ctx['filter'] = form.get('filter','all')
184 ctx['fiscalyear'] = fiscalyear.id193 ctx['fiscalyear'] = fiscalyear.id
185 ctx['periods'] = form.get('periods')194 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
186 if form['state'] in ['byperiod', 'all']:195 if form['filter'] in ['byperiod', 'all']:
187 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])196 ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])
188 ctx['periods'] = ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])197 if form['filter'] in ['bydate', 'all']:
189 if form['state'] in ['bydate', 'all']:
190 ctx['date_from'] = form['date_from']198 ctx['date_from'] = form['date_from']
191 ctx['date_to'] = form['date_to']199 ctx['date_to'] = form['date_to']
192200
193 accounts=[]201 accounts=[]
202
194 val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx)203 val = account_obj.browse(self.cr, self.uid, [aa_id[0] for aa_id in account_ids], ctx)
195 c = 0204 c = 0
196 for aa_id in account_ids:205 for aa_id in account_ids:
197 new_acc = {206 new_acc = {
198 'id' :val[c].id, 207 'id' :val[c].id,
199 'type' :val[c].type,208 'type' :val[c].type,
200 'code' :val[c].code,209 'code' :val[c].code,
201 'name' :val[c].name,210 'name' :val[c].name,
202 'debit' :val[c].debit,211 'debit' :val[c].debit,
203 'credit' :val[c].credit,212 'credit' :val[c].credit,
204 'parent_id' :val[c].parent_id and val[c].parent_id.id,213 'parent_id' :val[c].parent_id and val[c].parent_id.id,
205 'level' :val[c].level,214 'level' :val[c].level,
206 'label' :aa_id[1],215 'label' :aa_id[1],
207 'total' :aa_id[2],216 'total' :aa_id[2],
208 }217 }
209 c += 1218 c += 1
210 accounts.append(new_acc)219 accounts.append(new_acc)
@@ -214,11 +223,38 @@
214 fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or []223 fiscalyear_obj.search(self.cr, self.uid, [('date_stop','<',fiscalyear.date_start)],order='date_stop')[-1] or []
215 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)])224 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',ctx['fiscalyear']),('date_stop','<',fiscalyear.date_start)])
216 225
226 #############################################################################
227 # Calculate the period initial Balance #
228 # (fy balance minus the balance from the start of the selected period #
229 # to the end of the year) #
230 #############################################################################
231
232 ctx = self.context.copy()
233 ctx['filter'] = form.get('filter','all')
234 ctx['fiscalyear'] = fiscalyear.id
235
236 if form['filter'] in ['byperiod', 'all']:
237 ctx['periods'] = form['periods']
238 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
239 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
240 if not ctx['periods']:
241 missing_period()
242 elif form['filter'] in ['bydate']:
243 ctx['date_from'] = fiscalyear.date_start
244 ctx['date_to'] = form['date_from']
245 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])])
246 elif form['filter'] == 'none':
247 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])
248 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
249 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])
250
251 period_balanceinit = {}
252 for acc in account_obj.browse(self.cr, self.uid, [x[0] for x in account_ids], ctx):
253 period_balanceinit[acc['id']] = acc.balance
217254
218 #255 #
219 # Generate the report lines (checking each account)256 # Generate the report lines (checking each account)
220 #257 #
221
222 tot = {} 258 tot = {}
223 for account in accounts:259 for account in accounts:
224 account_id = account['id']260 account_id = account['id']
@@ -233,26 +269,31 @@
233 #269 #
234 # Check if we need to include this level270 # Check if we need to include this level
235 #271 #
236
237 if not form['display_account_level'] or account['level'] <= form['display_account_level']:272 if not form['display_account_level'] or account['level'] <= form['display_account_level']:
238
239 #273 #
240 # Copy the account values274 # Copy the account values
241 #275 #
242
243 res = {276 res = {
244 'id' : account_id,277 'id' : account_id,
245 'type' : account['type'],278 'type' : account['type'],
246 'code': account['code'],279 'code': account['code'],
247 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],280 'name': (account['total'] and not account['label']) and 'TOTAL %s'%(account['name'].upper()) or account['name'],
248 'level': account['level'],281 'level': account['level'],
282 'balanceinit': period_balanceinit[account_id],
249 'debit': account['debit'],283 'debit': account['debit'],
250 'credit': account['credit'],284 'credit': account['credit'],
285 'balance': period_balanceinit[account_id]+account['debit']-account['credit'],
251 'parent_id': account['parent_id'],286 'parent_id': account['parent_id'],
252 'bal_type': '',287 'bal_type': '',
253 'label': account['label'],288 'label': account['label'],
254 'total': account['total'],289 'total': account['total'],
255 }290 }
291 #
292 # Round the values to zero if needed (-0.000001 ~= 0)
293 #
294
295 if abs(res['balance']) < 0.5 * 10**-4:
296 res['balance'] = 0.0
256297
257 #298 #
258 # Check whether we must include this line in the report or not299 # Check whether we must include this line in the report or not
@@ -260,30 +301,31 @@
260301
261 if form['display_account'] == 'bal_mouvement' and account['parent_id']:302 if form['display_account'] == 'bal_mouvement' and account['parent_id']:
262 # Include accounts with movements303 # Include accounts with movements
263 if abs(res['credit']-res['debit']) >= 0.5 * 10**-int(2) \304 if abs(res['balance']) >= 0.5 * 10**-int(2):
264 or abs(res['credit']) >= 0.5 * 10**-int(2) \305 result_acc.append(res)
265 or abs(res['debit']) >= 0.5 * 10**-int(2):306 elif form['display_account'] == 'bal_solde' and account['parent_id']:
266 result_acc.append(res)307 # Include accounts with balance
267 elif form['display_account'] == 'bal_solde' and account['parent_id']:308 if abs(res['balance']) >= 0.5 * 10**-4:
268 # Include accounts with balance309 result_acc.append(res)
269 if abs(res['credit']-res['debit']) >= 0.5 * 10**-int(2):310 else:
270 result_acc.append(res)311 # Include all accounts
271 else:312 result_acc.append(res)
272 # Include all account
273 result_acc.append(res)
274
275 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):313 if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
276 tot[res['id']] = True314 tot[res['id']] = True
315 tot_bin += res['balanceinit']
277 tot_deb += res['debit']316 tot_deb += res['debit']
278 tot_crd += res['credit']317 tot_crd += res['credit']
318 tot_eje += res['balance']
279319
280 if form['tot_check']:320 if form['tot_check']:
281 str_label = form['lab_str']321 str_label = form['lab_str']
282 res2 = {322 res2 = {
283 'type' : 'view',323 'type' : 'view',
284 'name': 'TOTAL %s'%(str_label),324 'name': 'TOTAL %s'%(str_label),
325 'balanceinit': tot_bin,
285 'debit': tot_deb,326 'debit': tot_deb,
286 'credit': tot_crd,327 'credit': tot_crd,
328 'balance': tot_eje,
287 'label': False,329 'label': False,
288 'total': True,330 'total': True,
289 }331 }
290332
=== modified file 'account_financial_report/report/account_balance_4_cols.py'
--- account_financial_report/report/account_balance_4_cols.py 2012-01-02 22:27:49 +0000
+++ account_financial_report/report/account_balance_4_cols.py 2012-01-20 23:38:23 +0000
@@ -53,8 +53,8 @@
53 'lines': self.lines,53 'lines': self.lines,
54 'get_fiscalyear_text': self.get_fiscalyear_text,54 'get_fiscalyear_text': self.get_fiscalyear_text,
55 'get_periods_and_date_text': self.get_periods_and_date_text,55 'get_periods_and_date_text': self.get_periods_and_date_text,
56 'get_inf_text': self.get_informe_text,56 'get_informe_text': self.get_informe_text,
57 'get_month':self._get_month,57 'get_month':self.get_month,
58 })58 })
59 self.context = context59 self.context = context
6060
@@ -78,27 +78,30 @@
78 """78 """
79 inf_type = {79 inf_type = {
80 'bgen' : ' Balance General',80 'bgen' : ' Balance General',
81 'bcom' : ' Balance de Comprobacion',81 'bcom' : ' Balance de Comprobacion',
82 'edogp': 'Estado de Ganancias y Perdidas',82 'edogp': 'Estado de Ganancias y Perdidas'
83 'bml': 'Libro Mayor Legal',
84 }83 }
85 return inf_type[form['inf_type']]84 return inf_type[form['inf_type']]
8685
87 def _get_month(self, form):86 def get_month(self, form):
88 '''87 '''
89 return day, year and month88 return day, year and month
90 '''89 '''
9190 if form['filter'] in ['bydate', 'all']:
92 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]91 months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
9392 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
94 mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]93 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
95 ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]94 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
96 dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]95 return 'Período del '+self.formatLang(form['date_from'], date=True)+' al '+self.formatLang(form['date_to'], date=True)
9796 elif form['filter'] in ['byperiod', 'all']:
98 if form['inf_type']=='edogp':97 aux=[]
99 return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)98 period_obj = self.pool.get('account.period')
100 else:99
101 return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)100 for period in period_obj.browse(self.cr, self.uid, form['periods']):
101 aux.append(period.date_start)
102 aux.append(period.date_stop)
103 sorted(aux)
104 return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
102105
103 def get_periods_and_date_text(self, form):106 def get_periods_and_date_text(self, form):
104 """107 """
@@ -108,12 +111,12 @@
108 periods_str = None111 periods_str = None
109 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)112 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
110 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])113 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id),('special','=',False)])
111 if form['state'] in ['byperiod', 'all']:114 if form['filter'] in ['byperiod', 'all']:
112 period_ids = form['periods']115 period_ids = form['periods']
113 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])116 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
114117
115 dates_str = None118 dates_str = None
116 if form['state'] in ['bydate', 'all']:119 if form['filter'] in ['bydate', 'all']:
117 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '120 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
118 return {'periods':periods_str, 'date':dates_str}121 return {'periods':periods_str, 'date':dates_str}
119122
@@ -186,12 +189,12 @@
186 #############################################################################189 #############################################################################
187190
188 ctx = self.context.copy()191 ctx = self.context.copy()
189 ctx['state'] = form.get('state','all')192 ctx['filter'] = form.get('filter','all')
190 ctx['fiscalyear'] = fiscalyear.id193 ctx['fiscalyear'] = fiscalyear.id
191 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])194 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
192 if form['state'] in ['byperiod', 'all']:195 if form['filter'] in ['byperiod', 'all']:
193 ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])196 ctx['periods'] = period_obj.search(self.cr, self.uid, [('id','in',form['periods'] or ctx['periods']),('special','=',False)])
194 if form['state'] in ['bydate', 'all']:197 if form['filter'] in ['bydate', 'all']:
195 ctx['date_from'] = form['date_from']198 ctx['date_from'] = form['date_from']
196 ctx['date_to'] = form['date_to']199 ctx['date_to'] = form['date_to']
197200
@@ -227,20 +230,20 @@
227 #############################################################################230 #############################################################################
228 231
229 ctx = self.context.copy()232 ctx = self.context.copy()
230 ctx['state'] = form.get('state','all')233 ctx['filter'] = form.get('filter','all')
231 ctx['fiscalyear'] = fiscalyear.id234 ctx['fiscalyear'] = fiscalyear.id
232235
233 if form['state'] in ['byperiod', 'all']:236 if form['filter'] in ['byperiod', 'all']:
234 ctx['periods'] = form['periods']237 ctx['periods'] = form['periods']
235 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])238 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
236 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])239 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
237 if not ctx['periods']:240 if not ctx['periods']:
238 missing_period()241 missing_period()
239 elif form['state'] in ['bydate']:242 elif form['filter'] in ['bydate']:
240 ctx['date_from'] = fiscalyear.date_start243 ctx['date_from'] = fiscalyear.date_start
241 ctx['date_to'] = form['date_from']244 ctx['date_to'] = form['date_from']
242 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])])245 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',ctx['date_to'])])
243 elif form['state'] == 'none':246 elif form['filter'] == 'none':
244 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])247 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])
245 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])248 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
246 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])249 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])
247250
=== modified file 'account_financial_report/report/balance_full.rml'
--- account_financial_report/report/balance_full.rml 2012-01-02 22:27:49 +0000
+++ account_financial_report/report/balance_full.rml 2012-01-20 23:38:23 +0000
@@ -5,37 +5,26 @@
5 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>5 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
6 <pageGraphics>6 <pageGraphics>
7 <setFont name="Helvetica" size="9"/>7 <setFont name="Helvetica" size="9"/>
8
9<!--
10 <image x="1.0cm" y="25.0cm" height="2.5cm" width="9.6cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
11 <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
12-->
13
14 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm"> 8 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
15 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">9 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
16 <tr>10 <tr>
17 <td><para style="TOP_TITLE"></para></td>11 <td><para style="TOP_TITLE"></para></td>
18 <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>12 <td><para style="TITLE_CENTER_NAME">
19 </tr>13 <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
20 <tr>14 <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>
21 <td><para style="TOP_TITLE"></para></td>15 </para></td>
22 <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>16 </tr>
23 </tr>17 <tr>
24 <tr>18 <td><para style="TOP_TITLE"></para></td>
25 <td><para style="TOP_TITLE"></para></td>19 <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
26 <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
27 </tr>20 </tr>
28 <tr>21 <tr>
29 <td><para style="TOP_TITLE"></para></td>22 <td><para style="TOP_TITLE"></para></td>
30 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>23 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
31 </tr>24 </tr>
32 <tr>
33 <td><para style="TOP_TITLE"></para></td>
34 <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
35 </tr>
36 </blockTable>25 </blockTable>
37 </place>26 </place>
38 <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString> 27 <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
39 </pageGraphics>28 </pageGraphics>
4029
41 </pageTemplate>30 </pageTemplate>
@@ -108,7 +97,7 @@
108 <para style="TITLES">Cuenta</para>97 <para style="TITLES">Cuenta</para>
109 </td>98 </td>
110 <td>99 <td>
111 <para style="TITLE_LEFT_ALIGN"></para>100 <para style="TITLE_LEFT_ALIGN">Balance</para>
112 </td>101 </td>
113 </tr>102 </tr>
114 <tr>103 <tr>
@@ -127,7 +116,7 @@
127 <td>116 <td>
128 <para style="TITLE_LEFT_ALIGN">117 <para style="TITLE_LEFT_ALIGN">
129 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>118 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
130 <font>[[ (a['total']==True) and formatLang(a['balance']) or '']]</font>119 <font>[[(a['total']==True) and formatLang(a['balance']) or '']]</font>
131 </para>120 </para>
132 </td>121 </td>
133 </tr>122 </tr>
134123
=== modified file 'account_financial_report/report/balance_full_2_cols.rml'
--- account_financial_report/report/balance_full_2_cols.rml 2012-01-02 22:27:49 +0000
+++ account_financial_report/report/balance_full_2_cols.rml 2012-01-20 23:38:23 +0000
@@ -5,37 +5,26 @@
5 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>5 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>
6 <pageGraphics>6 <pageGraphics>
7 <setFont name="Helvetica" size="9"/>7 <setFont name="Helvetica" size="9"/>
8
9<!--
10 <image x="1.0cm" y="25.0cm" height="2.5cm" width="9.6cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
11 <drawString x="1.0cm" y="24.5cm">[[company.logo and removeParentNode('para') or company.name]]</drawString>
12-->
13
14 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm"> 8 <place x="-3.5cm" y="22.50cm" width="19cm" height="5.0cm">
15 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">9 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
16 <tr>10 <tr>
17 <td><para style="TOP_TITLE"></para></td>11 <td><para style="TOP_TITLE"></para></td>
18 <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>12 <td><para style="TITLE_CENTER_NAME">
19 </tr>13 <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
20 <tr>14 <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>
21 <td><para style="TOP_TITLE"></para></td>15 </para></td>
22 <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>16 </tr>
23 </tr>17 <tr>
24 <tr>18 <td><para style="TOP_TITLE"></para></td>
25 <td><para style="TOP_TITLE"></para></td>19 <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
26 <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
27 </tr>20 </tr>
28 <tr>21 <tr>
29 <td><para style="TOP_TITLE"></para></td>22 <td><para style="TOP_TITLE"></para></td>
30 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>23 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
31 </tr>24 </tr>
32 <tr>
33 <td><para style="TOP_TITLE"></para></td>
34 <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
35 </tr>
36 </blockTable>25 </blockTable>
37 </place>26 </place>
38 <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString> 27 <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
39 </pageGraphics>28 </pageGraphics>
4029
41 </pageTemplate>30 </pageTemplate>
@@ -43,7 +32,7 @@
43 <stylesheet>32 <stylesheet>
44 <blockTableStyle id="TITLE">33 <blockTableStyle id="TITLE">
45 <blockValign value="TOP"/>34 <blockValign value="TOP"/>
46 </blockTableStyle> 35 </blockTableStyle>
47 <blockTableStyle id="BODY">36 <blockTableStyle id="BODY">
48 <blockValign value="TOP"/>37 <blockValign value="TOP"/>
49 <blockAlignment value="RIGHT"/>38 <blockAlignment value="RIGHT"/>
@@ -75,32 +64,20 @@
75 alignment="RIGHT" 64 alignment="RIGHT"
76 spaceBefore="0.0" 65 spaceBefore="0.0"
77 spaceAfter="0.0"/>66 spaceAfter="0.0"/>
78 <paraStyle 67 <paraStyle name="TOP_TITLE" fontName="Helvetica-Bold" fontSize="9" leftIndent="0.0" alignment="LEFT"/>
79 name="TOP_TITLE" 68 <paraStyle name="TITLES" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
80 fontName="Helvetica-Bold"
81 fontSize="9"
82 leftIndent="0.0"
83 alignment="LEFT"/>
84 <paraStyle name="TITLES"
85 fontName="Helvetica-Bold"
86 fontSize="8.0"
87 leading="10"
88 alignment="LEFT"
89 spaceBefore="0.0"
90 spaceAfter="0.0"/>
91 <paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="9" leading="10" leftIndent="0.0" alignment="CENTER"/>69 <paraStyle name="TITLE_CENTER" fontName="Helvetica-Bold" fontSize="9" leading="10" leftIndent="0.0" alignment="CENTER"/>
92 <paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>70 <paraStyle name="TITLE_CENTER_NAME" fontName="Helvetica-Bold" fontSize="12" leading="13" leftIndent="0.0" alignment="CENTER"/>
93 <paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>71 <paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="18.0" leading="20" spaceBefore="-3.0" textColor="black"/>
94
95 </stylesheet>72 </stylesheet>
96 <images/>73 <images/>
97 <story>74 <story>
98 <para>[[setLang(user.context_lang)]]</para>75 <para>[[setLang(user.context_lang)]]</para>
99 <blockTable colWidths="2.5cm,11.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">76 <blockTable colWidths="2.5cm,9.5cm,3.5cm,3.5cm" style="BODY" repeatRows="1">
100 <tr noRowsplits="1">77 <tr noRowsplits="1">
101 <td>78 <td>
102 <para style="TITLE_LEFT_ALIGN">79 <para style="TITLE_LEFT_ALIGN">
103 <font>Código</font>80 <font>Código</font>
104 </para>81 </para>
105 </td>82 </td>
106 <td>83 <td>
@@ -119,7 +96,6 @@
119 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>96 <font>[[ a['type']&lt;&gt;'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
120 <i>[[a['label']==True and a['code'] or '' ]]</i>97 <i>[[a['label']==True and a['code'] or '' ]]</i>
121 </para>98 </para>
122
123 </td>99 </td>
124 <td>100 <td>
125 <para style="TITLES">101 <para style="TITLES">
126102
=== modified file 'account_financial_report/report/balance_full_4_cols.rml'
--- account_financial_report/report/balance_full_4_cols.rml 2012-01-02 22:27:49 +0000
+++ account_financial_report/report/balance_full_4_cols.rml 2012-01-20 23:38:23 +0000
@@ -2,7 +2,7 @@
2<document filename="test.pdf">2<document filename="test.pdf">
3 <template pageSize="(21.59cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">3 <template pageSize="(21.59cm,27.94cm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0">
4 <pageTemplate id="first">4 <pageTemplate id="first">
5 <frame id="first" x1="1cm" y1="1.0cm" width="19.0cm" height="23cm"/>5 <frame id="first" x1="0.5cm" y1="1.0cm" width="20.5cm" height="23cm"/>
6 <pageGraphics>6 <pageGraphics>
7 <setFont name="Helvetica" size="9"/>7 <setFont name="Helvetica" size="9"/>
88
@@ -15,27 +15,22 @@
15 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">15 <blockTable colWidths="9.6cm,9.4cm" style="TITLE">
16 <tr>16 <tr>
17 <td><para style="TOP_TITLE"></para></td>17 <td><para style="TOP_TITLE"></para></td>
18 <td><para style="TITLE_CENTER_NAME">[[ company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE' ]]</para></td>18 <td><para style="TITLE_CENTER_NAME">
19 </tr>19 <font>[[ (company.name and company.name or 'NOMBRE DE COMPANIA NO DISPONIBLE')]]</font>
20 <tr>20 <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>
21 <td><para style="TOP_TITLE"></para></td>21 </para></td>
22 <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>22 </tr>
23 </tr>23 <tr>
24 <tr>24 <td><para style="TOP_TITLE"></para></td>
25 <td><para style="TOP_TITLE"></para></td>25 <td><para style="TITLE_CENTER">[[ get_informe_text(data['form']) ]][[data['form'] and (' (Expresado en %s)'%( company.currency_id.name)) or '']]</para></td>
26 <td><para style="TITLE_CENTER">[[ get_inf_text(data['form']) ]]</para></td>
27 </tr>26 </tr>
28 <tr>27 <tr>
29 <td><para style="TOP_TITLE"></para></td>28 <td><para style="TOP_TITLE"></para></td>
30 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>29 <td><para style="TITLE_CENTER">[[data['form'] and get_month(data['form']) or '']]</para></td>
31 </tr>30 </tr>
32 <tr>
33 <td><para style="TOP_TITLE"></para></td>
34 <td><para style="TITLE_CENTER">[[data['form'] and ('(Expresado en %s)'%(company.currency_id.symbol)) or '']]</para></td>
35 </tr>
36 </blockTable>31 </blockTable>
37 </place>32 </place>
38 <drawRightString x="192mm" y="5mm">[[ get_inf_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString> 33 <drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
39 </pageGraphics>34 </pageGraphics>
4035
41 </pageTemplate>36 </pageTemplate>
@@ -84,7 +79,7 @@
84 <images/>79 <images/>
85 <story>80 <story>
86 <para>[[setLang(user.context_lang)]]</para>81 <para>[[setLang(user.context_lang)]]</para>
87 <blockTable colWidths="2.5cm,6.5cm,2.5cm,2.5cm,2.5cm,2.5cm" style="BODY" repeatRows="1">82 <blockTable colWidths="2.5cm,6.5cm,2.5cm,3.5cm,3.5cm,2.5cm" style="BODY" repeatRows="1">
88 <tr noRowsplits="1">83 <tr noRowsplits="1">
89 <td>84 <td>
90 <para style="TITLE_LEFT_ALIGN">85 <para style="TITLE_LEFT_ALIGN">
9186
=== modified file 'account_financial_report/wizard/account_report_wizard.xml'
--- account_financial_report/wizard/account_report_wizard.xml 2012-01-02 21:37:32 +0000
+++ account_financial_report/wizard/account_report_wizard.xml 2012-01-20 23:38:23 +0000
@@ -22,16 +22,16 @@
22 <separator string="Period" colspan="4"/>22 <separator string="Period" colspan="4"/>
23 <field name="fiscalyear"/>23 <field name="fiscalyear"/>
24 <newline/>24 <newline/>
25 <field name="state" required="True"/>25 <field name="filter" required="True"/>
26 <newline/>26 <newline/>
2727
28 <group attrs="{'invisible':[('state','=','none')]}" colspan="4">28 <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
29 <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">29 <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
30 <separator string="Date Filter" colspan="4"/>30 <separator string="Date Filter" colspan="4"/>
31 <field name="date_from"/>31 <field name="date_from"/>
32 <field name="date_to"/>32 <field name="date_to"/>
33 </group>33 </group>
34 <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">34 <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
35 <separator string="Filter on Periods" colspan="4"/>35 <separator string="Filter on Periods" colspan="4"/>
36 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>36 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
37 </group>37 </group>
@@ -87,15 +87,15 @@
87 <separator string="Period" colspan="4"/>87 <separator string="Period" colspan="4"/>
88 <field name="fiscalyear"/>88 <field name="fiscalyear"/>
89 <newline/>89 <newline/>
90 <field name="state" required="True"/>90 <field name="filter" required="True"/>
91 <newline/>91 <newline/>
92 <group attrs="{'invisible':[('state','=','none')]}" colspan="4">92 <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
93 <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">93 <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
94 <separator string="Date Filter" colspan="4"/>94 <separator string="Date Filter" colspan="4"/>
95 <field name="date_from"/>95 <field name="date_from"/>
96 <field name="date_to"/>96 <field name="date_to"/>
97 </group>97 </group>
98 <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">98 <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
99 <separator string="Filter on Periods" colspan="4"/>99 <separator string="Filter on Periods" colspan="4"/>
100 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>100 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
101 </group>101 </group>
@@ -149,15 +149,15 @@
149 <separator string="Period" colspan="4"/>149 <separator string="Period" colspan="4"/>
150 <field name="fiscalyear"/>150 <field name="fiscalyear"/>
151 <newline/>151 <newline/>
152 <field name="state" required="True"/>152 <field name="filter" required="True"/>
153 <newline/>153 <newline/>
154 <group attrs="{'invisible':[('state','=','none')]}" colspan="4">154 <group attrs="{'invisible':[('filter','=','none')]}" colspan="4">
155 <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">155 <group attrs="{'invisible':[('filter','=','byperiod')]}" colspan="4">
156 <separator string="Date Filter" colspan="4"/>156 <separator string="Date Filter" colspan="4"/>
157 <field name="date_from"/>157 <field name="date_from"/>
158 <field name="date_to"/>158 <field name="date_to"/>
159 </group>159 </group>
160 <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">160 <group attrs="{'invisible':[('filter','=','bydate')]}" colspan="4">
161 <separator string="Filter on Periods" colspan="4"/>161 <separator string="Filter on Periods" colspan="4"/>
162 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>162 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
163 </group>163 </group>
164164
=== modified file 'account_financial_report/wizard/wizard_account_balance_2_report.py'
--- account_financial_report/wizard/wizard_account_balance_2_report.py 2012-01-02 22:27:49 +0000
+++ account_financial_report/wizard/wizard_account_balance_2_report.py 2012-01-20 23:38:23 +0000
@@ -29,36 +29,47 @@
29from osv import osv,fields29from osv import osv,fields
30import pooler30import pooler
31import time31import time
32
32class wizard_account_balance_gene_2(osv.osv_memory):33class wizard_account_balance_gene_2(osv.osv_memory):
33 _name = "wizard.report.account.balance.gene.2"34 _name = "wizard.report.account.balance.gene.2"
3435
35 _columns = {36 _columns = {
36 'company_id': fields.many2one('res.company','Company',required=True),37 'company_id': fields.many2one('res.company','Company',required=True),
37 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),38 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
38 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),39 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
39 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),40 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
40 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),41 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
41 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),42 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
42 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),43 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
43 'date_from': fields.date('Start date',required=True),44 'date_from': fields.date('Start date'),
44 'date_to': fields.date('End date',required=True),45 'date_to': fields.date('End date'),
45 'tot_check': fields.boolean('Show Total'),46 'tot_check': fields.boolean('Show Total'),
46 'lab_str': fields.char('Description', size= 128),47 'lab_str': fields.char('Description', size= 128),
47 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bdl','Libro Diario Legal')],'Tipo Informe',required=True),48 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
49 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
48 }50 }
49 51
50 _defaults = {52 _defaults = {
51 'date_from': lambda *a: time.strftime('%Y-%m-%d'),53 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
52 'date_to': lambda *a: time.strftime('%Y-%m-%d'),54 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
53 'state': lambda *a:'byperiod',55 'filter': lambda *a:'byperiod',
54 'display_account_level': lambda *a: 0,56 'display_account_level': lambda *a: 0,
55 'inf_type': lambda *a:'bcom',57 'inf_type': lambda *a:'bcom',
56 'company_id': lambda *a: 1,58 'company_id': lambda *a: 1,
57 'fiscalyear': lambda *a: 1,59 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
58 'display_account': lambda *a:'bal_mouvement',60 'display_account': lambda *a:'con_movimiento',
59
60 }61 }
6162
63 def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
64 if context is None:
65 context = {}
66 res = {}
67 if filters in ("bydate","all"):
68 fisy = self.pool.get("account.fiscalyear")
69 fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
70 res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
71 return res
72
62 def _get_defaults(self, cr, uid, data, context=None):73 def _get_defaults(self, cr, uid, data, context=None):
63 if context is None:74 if context is None:
64 context = {}75 context = {}
@@ -73,40 +84,65 @@
73 data['form']['context'] = context84 data['form']['context'] = context
74 return data['form']85 return data['form']
7586
76
77 def _check_state(self, cr, uid, data, context=None):87 def _check_state(self, cr, uid, data, context=None):
78 if context is None:88 if context is None:
79 context = {}89 context = {}
80 if data['form']['state'] == 'bydate':90 if data['form']['filter'] == 'bydate':
81 self._check_date(cr, uid, data, context)91 self._check_date(cr, uid, data, context)
82 return data['form']92 return data['form']
83 93
84
85 def _check_date(self, cr, uid, data, context=None):94 def _check_date(self, cr, uid, data, context=None):
86 if context is None:95 if context is None:
87 context = {}96 context = {}
97
98 if data['form']['date_from'] > data['form']['date_to']:
99 raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
100
88 sql = """SELECT f.id, f.date_start, f.date_stop101 sql = """SELECT f.id, f.date_start, f.date_stop
89 FROM account_fiscalyear f102 FROM account_fiscalyear f
90 WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])103 WHERE '%s' = f.id """%(data['form']['fiscalyear'])
91 cr.execute(sql)104 cr.execute(sql)
92 res = cr.dictfetchall()105 res = cr.dictfetchall()
106
93 if res:107 if res:
94 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):108 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
95 raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))109 raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
96 else:110 else:
97 return 'report'111 return 'report'
98 else:112 else:
99 raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))113 raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
100114
101 def print_report(self, cr, uid, ids,data, context=None):115 def print_report(self, cr, uid, ids,data, context=None):
102 if context is None:116 if context is None:
103 context = {}117 context = {}
118
104 data = {}119 data = {}
105 data['ids'] = context.get('active_ids', [])120 data['ids'] = context.get('active_ids', [])
106 data['model'] = context.get('active_model', 'ir.ui.menu')121 data['model'] = context.get('active_model', 'ir.ui.menu')
107 data['form'] = self.read(cr, uid, ids[0])122 data['form'] = self.read(cr, uid, ids[0])
123
124 if data['form']['filter'] == 'byperiod':
125 del data['form']['date_from']
126 del data['form']['date_to']
127 elif data['form']['filter'] == 'bydate':
128 self._check_date(cr, uid, data)
129 del data['form']['periods']
130 elif data['form']['filter'] == 'none':
131 del data['form']['date_from']
132 del data['form']['date_to']
133 del data['form']['periods']
134 else:
135 self._check_date(cr, uid, data)
136 lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
137 sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
138 from account_period p
139 where p.id in %s"""%lis2
140 cr.execute(sqlmm)
141 minmax = cr.dictfetchall()
142 if minmax:
143 if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
144 raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
145
108 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene.2', 'datas': data}146 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene.2', 'datas': data}
109147
110wizard_account_balance_gene_2()148wizard_account_balance_gene_2()
111
112
113149
=== modified file 'account_financial_report/wizard/wizard_account_balance_4_report.py'
--- account_financial_report/wizard/wizard_account_balance_4_report.py 2012-01-02 22:27:49 +0000
+++ account_financial_report/wizard/wizard_account_balance_4_report.py 2012-01-20 23:38:23 +0000
@@ -1,37 +1,75 @@
1# -*- encoding: utf-8 -*-1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
5# All Rights Reserved
6###############Credits######################################################
7# Coded by: Humberto Arocha humberto@openerp.com.ve
8# Angelica Barrios angelicaisabelb@gmail.com
9# Jordi Esteve <jesteve@zikzakmedia.com>
10# Javier Duran <javieredm@gmail.com>
11# Planified by: Humberto Arocha
12# Finance by: LUBCAN COL S.A.S http://www.lubcancol.com
13# Audited by: Humberto Arocha humberto@openerp.com.ve
14#############################################################################
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27##############################################################################
28
2from osv import osv,fields29from osv import osv,fields
3import pooler30import pooler
4import time31import time
32
5class wizard_report(osv.osv_memory):33class wizard_report(osv.osv_memory):
6 _name = "wizard.report"34 _name = "wizard.report"
735
8 _columns = {36 _columns = {
9 'company_id': fields.many2one('res.company','Company',required=True),37 'company_id': fields.many2one('res.company','Company',required=True),
10 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),38 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
11 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),39 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
12 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),40 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
13 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),41 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
14 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),42 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
15 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),43 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
16 'date_from': fields.date('Start date',required=True),44 'date_from': fields.date('Start date'),
17 'date_to': fields.date('End date',required=True),45 'date_to': fields.date('End date'),
18 'tot_check': fields.boolean('Show Total'),46 'tot_check': fields.boolean('Show Total'),
19 'lab_str': fields.char('Description', size= 128),47 'lab_str': fields.char('Description', size= 128),
20 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas'),('bml','Libro Mayor Legal')],'Tipo Informe',required=True),48 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
49 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
21 }50 }
22 51
23 _defaults = {52 _defaults = {
24 'date_from': lambda *a: time.strftime('%Y-%m-%d'),53 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
25 'date_to': lambda *a: time.strftime('%Y-%m-%d'),54 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
26 'state': lambda *a:'byperiod',55 'filter': lambda *a:'byperiod',
27 'display_account_level': lambda *a: 0,56 'display_account_level': lambda *a: 0,
28 'inf_type': lambda *a:'bcom',57 'inf_type': lambda *a:'bcom',
29 'company_id': lambda *a: 1,58 'company_id': lambda *a: 1,
30 'fiscalyear': lambda *a: 1,59 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
31 'display_account': lambda *a:'bal_mouvement',60 'display_account': lambda *a:'con_movimiento',
32
33 }61 }
3462
63 def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
64 if context is None:
65 context = {}
66 res = {}
67 if filters in ("bydate","all"):
68 fisy = self.pool.get("account.fiscalyear")
69 fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
70 res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
71 return res
72
35 def _get_defaults(self, cr, uid, data, context=None):73 def _get_defaults(self, cr, uid, data, context=None):
36 if context is None:74 if context is None:
37 context = {}75 context = {}
@@ -46,38 +84,65 @@
46 data['form']['context'] = context84 data['form']['context'] = context
47 return data['form']85 return data['form']
4886
49
50 def _check_state(self, cr, uid, data, context=None):87 def _check_state(self, cr, uid, data, context=None):
51 if context is None:88 if context is None:
52 context = {}89 context = {}
53 if data['form']['state'] == 'bydate':90 if data['form']['filter'] == 'bydate':
54 self._check_date(cr, uid, data, context)91 self._check_date(cr, uid, data, context)
55 return data['form']92 return data['form']
56 93
57
58 def _check_date(self, cr, uid, data, context=None):94 def _check_date(self, cr, uid, data, context=None):
59 if context is None:95 if context is None:
60 context = {}96 context = {}
97
98 if data['form']['date_from'] > data['form']['date_to']:
99 raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
100
61 sql = """SELECT f.id, f.date_start, f.date_stop101 sql = """SELECT f.id, f.date_start, f.date_stop
62 FROM account_fiscalyear f102 FROM account_fiscalyear f
63 WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])103 WHERE '%s' = f.id """%(data['form']['fiscalyear'])
64 cr.execute(sql)104 cr.execute(sql)
65 res = cr.dictfetchall()105 res = cr.dictfetchall()
106
66 if res:107 if res:
67 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):108 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
68 raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))109 raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
69 else:110 else:
70 return 'report'111 return 'report'
71 else:112 else:
72 raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))113 raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
73114
74 def print_report(self, cr, uid, ids,data, context=None):115 def print_report(self, cr, uid, ids,data, context=None):
75 if context is None:116 if context is None:
76 context = {}117 context = {}
118
77 data = {}119 data = {}
78 data['ids'] = context.get('active_ids', [])120 data['ids'] = context.get('active_ids', [])
79 data['model'] = context.get('active_model', 'ir.ui.menu')121 data['model'] = context.get('active_model', 'ir.ui.menu')
80 data['form'] = self.read(cr, uid, ids[0])122 data['form'] = self.read(cr, uid, ids[0])
123
124 if data['form']['filter'] == 'byperiod':
125 del data['form']['date_from']
126 del data['form']['date_to']
127 elif data['form']['filter'] == 'bydate':
128 self._check_date(cr, uid, data)
129 del data['form']['periods']
130 elif data['form']['filter'] == 'none':
131 del data['form']['date_from']
132 del data['form']['date_to']
133 del data['form']['periods']
134 else:
135 self._check_date(cr, uid, data)
136 lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
137 sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
138 from account_period p
139 where p.id in %s"""%lis2
140 cr.execute(sqlmm)
141 minmax = cr.dictfetchall()
142 if minmax:
143 if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
144 raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
145
81 return {'type': 'ir.actions.report.xml', 'report_name': 'wizard.report.reporte', 'datas': data}146 return {'type': 'ir.actions.report.xml', 'report_name': 'wizard.report.reporte', 'datas': data}
82147
83wizard_report()148wizard_report()
84149
=== modified file 'account_financial_report/wizard/wizard_account_balance_report.py'
--- account_financial_report/wizard/wizard_account_balance_report.py 2012-01-02 21:37:32 +0000
+++ account_financial_report/wizard/wizard_account_balance_report.py 2012-01-20 23:38:23 +0000
@@ -26,40 +26,50 @@
26# along with this program. If not, see <http://www.gnu.org/licenses/>.26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27##############################################################################27##############################################################################
2828
29
30from osv import osv,fields29from osv import osv,fields
31import pooler30import pooler
32import time31import time
32
33class wizard_account_balance_gene(osv.osv_memory):33class wizard_account_balance_gene(osv.osv_memory):
34 _name = "wizard.report.account.balance.gene"34 _name = "wizard.report.account.balance.gene"
3535
36 _columns = {36 _columns = {
37 'company_id': fields.many2one('res.company','Company',required=True),37 'company_id': fields.many2one('res.company','Company',required=True),
38 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),38 'account_list': fields.many2many ('account.account','rel_wizard_account','account_list','account_id','Root accounts',required=True),
39 'state': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),39 'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
40 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),40 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal year',help='Keep empty to use all open fiscal years to compute the balance',required=True),
41 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),41 'periods': fields.many2many('account.period','rel_wizard_period','wizard_id','period_id','Periods',help='All periods in the fiscal year if empty'),
42 'display_account': fields.selection([('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')],'Display accounts'),42 'display_account': fields.selection([('all','All'),('con_balance', 'With balance'),('con_movimiento','With movements')],'Display accounts'),
43 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),43 'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
44 'date_from': fields.date('Start date',required=True),44 'date_from': fields.date('Start date'),
45 'date_to': fields.date('End date',required=True),45 'date_to': fields.date('End date'),
46 'tot_check': fields.boolean('Show Total'),46 'tot_check': fields.boolean('Show Total'),
47 'lab_str': fields.char('Description', size= 128),47 'lab_str': fields.char('Description', size= 128),
48 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),48 'inf_type': fields.selection([('bgen','Balance General'),('bcom','Balance Comprobacion'),('edogp','Estado Ganancias y Perdidas')],'Tipo Informe',required=True),
49 #~ 'type_report': fields.selection([('un_col','Una Columna'),('dos_col','Dos Columnas'),('cuatro_col','Cuatro Columnas')],'Tipo Informe',required=True),
49 }50 }
50 51
51 _defaults = {52 _defaults = {
52 'date_from': lambda *a: time.strftime('%Y-%m-%d'),53 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
53 'date_to': lambda *a: time.strftime('%Y-%m-%d'),54 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
54 'state': lambda *a:'byperiod',55 'filter': lambda *a:'byperiod',
55 'display_account_level': lambda *a: 0,56 'display_account_level': lambda *a: 0,
56 'inf_type': lambda *a:'bcom',57 'inf_type': lambda *a:'bcom',
57 'company_id': lambda *a: 1,58 'company_id': lambda *a: 1,
58 'fiscalyear': lambda *a: 1,59 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
59 'display_account': lambda *a:'bal_mouvement',60 'display_account': lambda *a:'con_movimiento',
60
61 }61 }
6262
63 def onchange_filter(self,cr,uid,ids,fiscalyear,filters,context=None):
64 if context is None:
65 context = {}
66 res = {}
67 if filters in ("bydate","all"):
68 fisy = self.pool.get("account.fiscalyear")
69 fis_actual = fisy.browse(cr,uid,fiscalyear,context=context)
70 res = {'value':{'date_from': fis_actual.date_start, 'date_to': fis_actual.date_stop}}
71 return res
72
63 def _get_defaults(self, cr, uid, data, context=None):73 def _get_defaults(self, cr, uid, data, context=None):
64 if context is None:74 if context is None:
65 context = {}75 context = {}
@@ -74,39 +84,65 @@
74 data['form']['context'] = context84 data['form']['context'] = context
75 return data['form']85 return data['form']
7686
77
78 def _check_state(self, cr, uid, data, context=None):87 def _check_state(self, cr, uid, data, context=None):
79 if context is None:88 if context is None:
80 context = {}89 context = {}
81 if data['form']['state'] == 'bydate':90 if data['form']['filter'] == 'bydate':
82 self._check_date(cr, uid, data, context)91 self._check_date(cr, uid, data, context)
83 return data['form']92 return data['form']
84 93
85
86 def _check_date(self, cr, uid, data, context=None):94 def _check_date(self, cr, uid, data, context=None):
87 if context is None:95 if context is None:
88 context = {}96 context = {}
97
98 if data['form']['date_from'] > data['form']['date_to']:
99 raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
100
89 sql = """SELECT f.id, f.date_start, f.date_stop101 sql = """SELECT f.id, f.date_start, f.date_stop
90 FROM account_fiscalyear f102 FROM account_fiscalyear f
91 WHERE '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])103 WHERE '%s' = f.id """%(data['form']['fiscalyear'])
92 cr.execute(sql)104 cr.execute(sql)
93 res = cr.dictfetchall()105 res = cr.dictfetchall()
106
94 if res:107 if res:
95 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):108 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
96 raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop']))109 raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
97 else:110 else:
98 return 'report'111 return 'report'
99 else:112 else:
100 raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))113 raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
101114
102 def print_report(self, cr, uid, ids,data, context=None):115 def print_report(self, cr, uid, ids,data, context=None):
103 if context is None:116 if context is None:
104 context = {}117 context = {}
118
105 data = {}119 data = {}
106 data['ids'] = context.get('active_ids', [])120 data['ids'] = context.get('active_ids', [])
107 data['model'] = context.get('active_model', 'ir.ui.menu')121 data['model'] = context.get('active_model', 'ir.ui.menu')
108 data['form'] = self.read(cr, uid, ids[0])122 data['form'] = self.read(cr, uid, ids[0])
123
124 if data['form']['filter'] == 'byperiod':
125 del data['form']['date_from']
126 del data['form']['date_to']
127 elif data['form']['filter'] == 'bydate':
128 self._check_date(cr, uid, data)
129 del data['form']['periods']
130 elif data['form']['filter'] == 'none':
131 del data['form']['date_from']
132 del data['form']['date_to']
133 del data['form']['periods']
134 else:
135 self._check_date(cr, uid, data)
136 lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
137 sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
138 from account_period p
139 where p.id in %s"""%lis2
140 cr.execute(sqlmm)
141 minmax = cr.dictfetchall()
142 if minmax:
143 if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
144 raise osv.except_osv(_('Error !'),('La intersepcion entre el periodo y fecha es vacio'))
145
109 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene', 'datas': data}146 return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance.gene', 'datas': data}
110147
111wizard_account_balance_gene()148wizard_account_balance_gene()
112

Subscribers

People subscribed via source and target branches

to all changes: