~openerp-community/openobject-addons/taktik

« back to all changes in this revision

Viewing changes to point_of_sale/wizard/wizard_pos_entry_report.py

  • Committer: Fabien Lydoire
  • Date: 2010-01-08 12:48:56 UTC
  • Revision ID: fl@taktik.be-20100108124856-j2ccwjqbuybn0hht
betterĀ posĀ module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import wizard
 
2
import time
 
3
import calendar
 
4
 
 
5
report_form = """<?xml version="1.0"?>
 
6
<form string="Report of cash entries :">
 
7
    <field name="date_start" />
 
8
    <field name="date_stop"/>
 
9
</form>
 
10
"""
 
11
 
 
12
report_fields = {
 
13
    'date_start': {'string': 'Start date', 'type': 'date'},    
 
14
    'date_stop': {'string': 'End date', 'type': 'date'},
 
15
    }
 
16
 
 
17
def _init(self, cr, uid, data, context):
 
18
    today_s = time.strftime('%Y-%m-%d')
 
19
    today = time.strptime(today_s,"%Y-%m-%d")
 
20
    year = time.strftime("%Y",today)
 
21
    month = time.strftime("%m",today)
 
22
    return {'date_start': today_s[:-3]+"-01",
 
23
            'date_stop' : today_s[:-3]+"-"+str(calendar.monthrange(int(year),int(month))[1])}
 
24
 
 
25
class pos_entry_report(wizard.interface):
 
26
    states = {
 
27
       'init' : {'actions' : [_init],
 
28
                'result' : {
 
29
                    'type': 'form',
 
30
                    'arch': report_form,
 
31
                    'fields': report_fields,
 
32
                    'state': [('end','Cancel','gtk-cancel'),
 
33
                              ('report', 'Report', 'gtk-ok', True)],
 
34
            }
 
35
        },
 
36
        'report': {
 
37
            'actions': [],
 
38
            'result': {
 
39
                'type': 'print',
 
40
                'report': 'pos.entry',
 
41
                'state': 'end'
 
42
            }
 
43
        },
 
44
    }
 
45
 
 
46
pos_entry_report('pos.entry_report')