~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to point_of_sale/wizard/wizard_add_product.py

  • Committer: Mantavya Gajjar
  • Date: 2009-12-01 10:19:51 UTC
  • mfrom: (4060.1.16 trunk-extra-addons)
  • Revision ID: mga@tinyerp.com-20091201101951-cpznxoapupixro3p
[MERGE]: merging from same branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution   
 
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
6
#    $Id$
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
import pooler
 
24
import wizard
 
25
 
 
26
 
 
27
_form = """<?xml version="1.0"?>
 
28
<form string="Add product :">
 
29
<field name="product"/>
 
30
<field name="quantity"/>
 
31
</form>
 
32
"""
 
33
_fields = {
 
34
    'product': {
 
35
        'string': 'Product',
 
36
        'type': 'many2one',
 
37
        'relation': 'product.product',
 
38
        'required': True,
 
39
        'default': False
 
40
    },
 
41
 
 
42
    'quantity': {
 
43
        'string': 'Quantity',
 
44
        'type': 'integer',
 
45
        'required': True,
 
46
        'default': 1},
 
47
    }
 
48
 
 
49
 
 
50
def _add(self, cr, uid, data, context):
 
51
    pool = pooler.get_pool(cr.dbname)
 
52
    order_obj = pool.get('pos.order')
 
53
    order_obj.add_product(cr, uid, data['id'], data['form']['product'],
 
54
                            data['form']['quantity'], context=context)
 
55
 
 
56
    return {}
 
57
 
 
58
 
 
59
def _pre_init(self, cr, uid, data, context):
 
60
    return {'product': False, 'quantity': 1}
 
61
 
 
62
 
 
63
class add_product(wizard.interface):
 
64
 
 
65
    states = {
 
66
        'init': {
 
67
            'actions': [_pre_init],
 
68
            'result': {
 
69
                'type': 'form',
 
70
                'arch': _form,
 
71
                'fields': _fields,
 
72
                'state': [('end', 'Cancel'), ('add', '_Add product', 'gtk-ok', True)
 
73
                ]
 
74
            }
 
75
        },
 
76
        'add': {
 
77
            'actions': [_add],
 
78
            'result': {
 
79
                'type': 'state',
 
80
                'state': 'init',
 
81
            }
 
82
        },
 
83
    }
 
84
 
 
85
add_product('pos.add_product')
 
86
 
 
87
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
88