~vauxoo/addons-vauxoo/7.0-account_move_folio-dev-hbto

« back to all changes in this revision

Viewing changes to account_chart_wiz_dates/wizard/account_chart.py

  • Committer: Luis Tores
  • Date: 2012-11-06 00:41:46 UTC
  • mto: (501.1.76 6.1)
  • mto: This revision was merged to the branch mainline in revision 529.
  • Revision ID: luis_t@vauxoo.com-20121106004146-6kwskt12vphaqs11
[ADD][account_chart_wiz_dates]Add fields for filter by date in wizard the account_chart

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#
 
5
#    Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
 
6
#    All Rights Reserved.
 
7
#    info Vauxoo (info@vauxoo.com)
 
8
############################################################################
 
9
#    Coded by: Luis Torres (luis_t@vauxoo.com)
 
10
############################################################################
 
11
#
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as
 
14
#    published by the Free Software Foundation, either version 3 of the
 
15
#    License, or (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
#
 
25
##############################################################################
 
26
from osv import fields, osv
 
27
import time
 
28
 
 
29
class account_chart(osv.osv_memory):
 
30
    _inherit= "account.chart"
 
31
    
 
32
    _columns={
 
33
        'filter':fields.selection([ ('filter_no','Unfiltered'), ('periods','Periods'), ('dates','Dates')],'Filter',),
 
34
        'initial_date': fields.date('Initial date',),
 
35
        'end_date': fields.date('End date',),
 
36
        }
 
37
    
 
38
    _defaults = {
 
39
        'filter': 'filter_no',
 
40
        }
 
41
        
 
42
    def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, val_filter=False, context=None):
 
43
        res={}
 
44
        if val_filter=='periods':
 
45
            res=super(account_chart, self).onchange_fiscalyear(cr, uid, ids, fiscalyear_id=fiscalyear_id, context=context)
 
46
        return res
 
47
        
 
48
    def onchange_val_filter(self, cr, uid, ids, val_filter=False, fiscalyear_id=False, context=None):
 
49
        res = {}
 
50
        if val_filter=='dates':
 
51
            res['value'] = {'period_from': False, 'period_to': False, 'initial_date': time.strftime('%Y-01-01'), 'end_date': time.strftime('%Y-%m-%d')}
 
52
        elif val_filter=='periods':
 
53
            res=super(account_chart, self).onchange_fiscalyear(cr, uid, ids, fiscalyear_id=fiscalyear_id, context=context)
 
54
            res['value']['initial_date']= False
 
55
            res['value']['end_date']= False
 
56
        elif val_filter=='filter_no':
 
57
            res['value'] = {'period_from': False, 'period_to': False, 'initial_date': False, 'end_date': False}
 
58
        return res
 
59
    
 
60
    def account_chart_open_window(self, cr, uid, ids, context=None):
 
61
        print 'ids', self.browse(cr, uid, ids)
 
62
        res=super(account_chart, self).account_chart_open_window(cr, uid, ids, context=context)
 
63
        print 'res', res
 
64
        return res