1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
25 from openerp import tools
26 from openerp.osv import fields, osv
27 from openerp.tools.translate import _
29 _logger = logging.getLogger(__name__)
31 class restaurant_floor(osv.osv):
32 _name = 'restaurant.floor'
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 'sequence': fields.integer('Sequence',help='Used to sort Floors'),
45 class restaurant_table(osv.osv):
46 _name = 'restaurant.table'
48 'name': fields.char('Table Name', size=32, required=True, help='An internal identification of a table'),
49 'floor_id': fields.many2one('restaurant.floor','Floor'),
50 'shape': fields.selection([('square','Square'),('round','Round')],'Shape', required=True),
51 'position_h': fields.float('Horizontal Position', help="The table's horizontal position from the left side to the table's center, in percentage of the floor's width"),
52 'position_v': fields.float('Vertical Position', help="The table's vertical position from the top to the table's center, in percentage of the floor's height"),
53 'width': fields.float('Width', help="The table's width in percentage of the floor's width"),
54 'height': fields.float('Height', help="The table's height in percentage of the floor's height"),
55 'color': fields.char('Color', size=32, help="The table's color"),
56 'active': fields.boolean('Active',help='If false, the table is deactivated and will not be available in the point of sale'),
57 'pos_order_ids':fields.one2many('pos.order','table_id','Pos Orders', help='The orders served at this table'),
69 def create_from_ui(self, cr, uid, table, context=None):
70 """ create or modify a table from the point of sale UI.
71 table contains the table's fields. If it contains an
72 id, it will modify the existing table. It then
73 returns the id of the table. """
75 if table.get('floor_id',False):
76 floor_id = table['floor_id'][0]
77 table['floor_id'] = floor_id
79 if table.get('id',False): # Modifiy existing table
80 table_id = table['id']
82 self.write(cr, uid, [table_id], table, context=context)
84 table_id = self.create(cr, uid, table, context=context)
88 class restaurant_printer(osv.osv):
89 _name = 'restaurant.printer'
92 'name' : fields.char('Printer Name', size=32, required=True, help='An internal identification of the printer'),
93 'proxy_ip': fields.char('Proxy IP Address', size=32, help="The IP Address or hostname of the Printer's hardware proxy"),
94 'product_categories_ids': fields.many2many('pos.category','printer_category_rel', 'printer_id','category_id',string='Printed Product Categories'),
101 class pos_config(osv.osv):
102 _inherit = 'pos.config'
104 'iface_splitbill': fields.boolean('Bill Splitting', help='Enables Bill Splitting in the Point of Sale'),
105 'iface_printbill': fields.boolean('Bill Printing', help='Allows to print the Bill before payment'),
106 'iface_floorplan': fields.boolean('Floor Plan', help='Enable Floor and Tables in the Point of Sale'),
107 'floor_ids': fields.one2many('restaurant.floor','pos_config_id','Restaurant Floors', help='The restaurant floors served by this point of sale'),
108 'printer_ids': fields.many2many('restaurant.printer','pos_config_printer_rel', 'config_id','printer_id',string='Order Printers'),
111 'iface_splitbill': False,
112 'iface_printbill': False,
113 'iface_floorplan': False,
116 class pos_order(osv.osv):
117 _inherit = 'pos.order'
119 'table_id': fields.many2one('restaurant.table','Table', help='The table where this order was served'),