~luc-demeyer/openobject-addons/7.0-account_financial_report_webkit-fixes

« back to all changes in this revision

Viewing changes to account_financial_report/report/account_balance_4_cols.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-20 23:53:06 UTC
  • mfrom: (5.1.2 miguel-bug-918857)
  • Revision ID: gabrielaquilarque97@gmail.com-20120120235306-jwp7ck633wj32lz7

[MERGE] Merge from lp:~vauxoo/account-financial-report/miguel-bug-918857.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
58
58
        })
59
59
        self.context = context
60
60
 
78
78
        """
79
79
        inf_type = {
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' 
84
83
        }
85
84
        return inf_type[form['inf_type']]
86
85
 
87
 
    def _get_month(self, form):
 
86
    def get_month(self, form):
88
87
        '''
89
88
        return day, year and month
90
89
        '''
91
 
 
92
 
        months=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]
93
 
 
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]
97
 
 
98
 
        if form['inf_type']=='edogp':
99
 
            return 'DESDE: '+self.formatLang(form['date_from'], date=True)+'  HASTA: '+self.formatLang(form['date_to'], date=True)
100
 
        else:
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']:
 
97
            aux=[]
 
98
            period_obj = self.pool.get('account.period')
 
99
            
 
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)
102
105
 
103
106
    def get_periods_and_date_text(self, form):
104
107
        """
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)])
114
117
 
115
118
        dates_str = None
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}
119
122
 
186
189
        #############################################################################
187
190
 
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']
197
200
 
227
230
        #############################################################################
228
231
        
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
232
235
 
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']:
238
241
                missing_period()
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)])