~openerp-community/openobject-addons/taktik

« back to all changes in this revision

Viewing changes to point_of_sale/wizard/wizard_pos_opening.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 pooler
 
3
from osv import osv
 
4
 
 
5
opening_form = """<?xml version="1.0"?>
 
6
<form string="Open cash drawer:">
 
7
    <field name="amount" />
 
8
</form>
 
9
"""
 
10
 
 
11
opening_fields = {
 
12
    'amount': {'string': 'Amount', 'type': 'float'},    
 
13
}    
 
14
 
 
15
def init(self, cr, uid, data, context):
 
16
    pool = pooler.get_pool(cr.dbname)
 
17
    opening_obj = pool.get('pos.opening')
 
18
    if opening_obj.is_pos_opened(cr, uid):
 
19
        raise osv.except_osv(_('The cash drawer is already opened !'), _('You can not open an already opened cash drawer'))
 
20
    return {}
 
21
 
 
22
def open_cash_drawer(self, cr, uid, data, context):
 
23
    pool = pooler.get_pool(cr.dbname)
 
24
    opening_obj = pool.get('pos.opening')
 
25
    opening_obj.open(cr,uid,data['form']['amount'])
 
26
    return {}
 
27
 
 
28
class pos_opening(wizard.interface):
 
29
    states = {
 
30
       'init' : {'actions' : [init],
 
31
                'result' : {
 
32
                    'type': 'form',
 
33
                    'arch': opening_form,
 
34
                    'fields': opening_fields,
 
35
                    'state': [('end','Cancel','gtk-cancel'),
 
36
                              ('open', 'Open', 'gtk-ok', True)],
 
37
            }
 
38
        },
 
39
        'open': {
 
40
            'actions': [open_cash_drawer],
 
41
             'result': {
 
42
                'type': 'state',
 
43
                'state': 'end'
 
44
            }
 
45
        },
 
46
    }
 
47
pos_opening('pos.opening')
 
 
b'\\ No newline at end of file'