flectra/addons/pos_restaurant/models/pos_restaurant.py
2018-01-16 02:34:37 -08:00

61 lines
3.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, fields, models
class RestaurantFloor(models.Model):
_name = 'restaurant.floor'
name = fields.Char('Floor Name', required=True, help='An internal identification of the restaurant floor')
pos_config_id = fields.Many2one('pos.config', string='Point of Sale')
background_image = fields.Binary('Background Image', attachment=True, help='A background image used to display a floor layout in the point of sale interface')
background_color = fields.Char('Background Color', help='The background color of the floor layout, (must be specified in a html-compatible format)', default='rgb(210, 210, 210)')
table_ids = fields.One2many('restaurant.table', 'floor_id', string='Tables', help='The list of tables in this floor')
sequence = fields.Integer('Sequence', help='Used to sort Floors', default=1)
class RestaurantTable(models.Model):
_name = 'restaurant.table'
name = fields.Char('Table Name', required=True, help='An internal identification of a table')
floor_id = fields.Many2one('restaurant.floor', string='Floor')
shape = fields.Selection([('square', 'Square'), ('round', 'Round')], string='Shape', required=True, default='square')
position_h = fields.Float('Horizontal Position', default=10,
help="The table's horizontal position from the left side to the table's center, in pixels")
position_v = fields.Float('Vertical Position', default=10,
help="The table's vertical position from the top to the table's center, in pixels")
width = fields.Float('Width', default=50, help="The table's width in pixels")
height = fields.Float('Height', default=50, help="The table's height in pixels")
seats = fields.Integer('Seats', default=1, help="The default number of customer served at this table.")
color = fields.Char('Color', help="The table's color, expressed as a valid 'background' CSS property value")
active = fields.Boolean('Active', default=True, help='If false, the table is deactivated and will not be available in the point of sale')
@api.model
def create_from_ui(self, table):
""" create or modify a table from the point of sale UI.
table contains the table's fields. If it contains an
id, it will modify the existing table. It then
returns the id of the table.
"""
if table.get('floor_id'):
table['floor_id'] = table['floor_id'][0]
table_id = table.pop('id', False)
if table_id:
self.browse(table_id).write(table)
else:
table_id = self.create(table).id
return table_id
class RestaurantPrinter(models.Model):
_name = 'restaurant.printer'
name = fields.Char('Printer Name', required=True, default='Printer', help='An internal identification of the printer')
proxy_ip = fields.Char('Proxy IP Address', help="The IP Address or hostname of the Printer's hardware proxy")
product_categories_ids = fields.Many2many('pos.category', 'printer_category_rel', 'printer_id', 'category_id', string='Printed Product Categories')