[WIP] pos_restaurant: floor and tables in the pos
[odoo/odoo.git] / addons / pos_restaurant / restaurant.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import logging
23
24 import openerp
25 from openerp import tools
26 from openerp.osv import fields, osv
27 from openerp.tools.translate import _
28
29 _logger = logging.getLogger(__name__)
30
31 class restaurant_floor(osv.osv):
32     _name = 'restaurant.floor'
33     _columns = {
34         'name':             fields.char('Floor Name', size=32, required=True, help='An internal identification of the restaurant floor'),
35         'pos_config_id':    fields.many2one('pos.config','Point of Sale'),
36         'background_image': fields.binary('Background Image', help='A background image used to display a floor layout in the point of sale interface'),  
37         'table_ids':        fields.one2many('restaurant.table','floor_id','Tables', help='The list of tables in this floor'),
38     }
39
40 class restaurant_table(osv.osv):
41     _name = 'restaurant.table'
42     _columns = {
43         'name':         fields.char('Table Name', size=32, required=True, help='An internal identification of a table'),
44         'floor_id':     fields.many2one('restaurant.floor','Floor'),
45         'shape':        fields.selection([('square','Square'),('round','Round')],'Shape', required=True),
46         'position_h':   fields.integer('Horizontal Position', help="The table's horizontal position from the left side to the table's center, in percentage of the floor's width"),
47         'position_v':   fields.integer('Vertical Position', help="The table's vertical position from the top to the table's center, in percentage of the floor's height"),
48         'width':        fields.integer('Width', help="The table's width in percentage of the floor's width"),
49         'height':       fields.integer('Height', help="The table's height in percentage of the floor's height"),
50         'color':        fields.char('Color', size=32, help="The table's color"),
51     }
52     _defaults = {
53         'shape': 'square',
54         'height': 10,
55         'width':  10,
56     }
57
58 class restaurant_printer(osv.osv):
59     _name = 'restaurant.printer'
60
61     _columns = {
62         'name' : fields.char('Printer Name', size=32, required=True, help='An internal identification of the printer'),
63         'proxy_ip': fields.char('Proxy IP Address', size=32, help="The IP Address or hostname of the Printer's hardware proxy"),
64         'product_categories_ids': fields.many2many('pos.category','printer_category_rel', 'printer_id','category_id',string='Printed Product Categories'),
65     }
66
67     _defaults = {
68         'name' : 'Printer',
69     }
70
71 class pos_config(osv.osv):
72     _inherit = 'pos.config'
73     _columns = {
74         'iface_splitbill': fields.boolean('Bill Splitting', help='Enables Bill Splitting in the Point of Sale'),
75         'iface_printbill': fields.boolean('Bill Printing', help='Allows to print the Bill before payment'),
76         'floor_ids':       fields.one2many('restaurant.floor','pos_config_id','Restaurant Floors', help='The restaurant floors served by this point of sale'),
77         'printer_ids':     fields.many2many('restaurant.printer','pos_config_printer_rel', 'config_id','printer_id',string='Order Printers'),
78     }
79     _defaults = {
80         'iface_splitbill': False,
81         'iface_printbill': False,
82     }
83