53
53
'lines': self.lines,
54
54
'get_fiscalyear_text': self.get_fiscalyear_text,
55
55
'get_periods_and_date_text': self.get_periods_and_date_text,
56
'get_inf_text': self.get_informe_text,
57
'get_month':self._get_month,
56
'get_informe_text': self.get_informe_text,
57
'get_month':self.get_month,
59
59
self.context = context
80
80
'bgen' : ' Balance General',
81
'bcom' : ' Balance de Comprobacion',
82
'edogp': 'Estado de Ganancias y Perdidas',
83
'bml': 'Libro Mayor Legal',
81
'bcom' : ' Balance de Comprobacion',
82
'edogp': 'Estado de Ganancias y Perdidas'
85
84
return inf_type[form['inf_type']]
87
def _get_month(self, form):
86
def get_month(self, form):
89
88
return day, year and month
92
months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
94
mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
95
ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
96
dia = time.strptime(form['date_to'],"%Y-%m-%d")[2]
98
if form['inf_type']=='edogp':
99
return 'DESDE: '+self.formatLang(form['date_from'], date=True)+' HASTA: '+self.formatLang(form['date_to'], date=True)
101
return 'AL '+str(dia) + ' DE ' + mes.upper() + ' DE ' + str(ano)
90
if form['filter'] in ['bydate', 'all']:
91
months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
92
mes = months[time.strptime(form['date_to'],"%Y-%m-%d")[1]-1]
93
ano = time.strptime(form['date_to'],"%Y-%m-%d")[0]
94
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)
96
elif form['filter'] in ['byperiod', 'all']:
98
period_obj = self.pool.get('account.period')
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)
104
return 'Período del '+self.formatLang(aux[0], date=True)+' al '+self.formatLang(aux[-1], date=True)
103
106
def get_periods_and_date_text(self, form):
108
111
periods_str = None
109
112
fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
110
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
115
period_ids = form['periods']
113
116
periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
116
if form['state'] in ['bydate', 'all']:
119
if form['filter'] in ['bydate', 'all']:
117
120
dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
118
121
return {'periods':periods_str, 'date':dates_str}
186
189
#############################################################################
188
191
ctx = self.context.copy()
189
ctx['state'] = form.get('state','all')
192
ctx['filter'] = form.get('filter','all')
190
193
ctx['fiscalyear'] = fiscalyear.id
191
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
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
198
ctx['date_from'] = form['date_from']
196
199
ctx['date_to'] = form['date_to']
227
230
#############################################################################
229
232
ctx = self.context.copy()
230
ctx['state'] = form.get('state','all')
233
ctx['filter'] = form.get('filter','all')
231
234
ctx['fiscalyear'] = fiscalyear.id
233
if form['state'] in ['byperiod', 'all']:
236
if form['filter'] in ['byperiod', 'all']:
234
237
ctx['periods'] = form['periods']
235
238
date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
236
239
ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_stop','<=',date_start)])
237
240
if not ctx['periods']:
239
elif form['state'] in ['bydate']:
242
elif form['filter'] in ['bydate']:
240
243
ctx['date_from'] = fiscalyear.date_start
241
244
ctx['date_to'] = form['date_from']
242
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
247
ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',True)])
245
248
date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
246
249
ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','<=',date_start),('special','=',True)])