Merge branch 'master-pos-wms-fva'
[odoo/odoo.git] / addons / pos_restaurant / restaurant.py
index c7d02a3..07b61b9 100644 (file)
@@ -28,6 +28,63 @@ from openerp.tools.translate import _
 
 _logger = logging.getLogger(__name__)
 
+class restaurant_floor(osv.osv):
+    _name = 'restaurant.floor'
+    _columns = {
+        'name':             fields.char('Floor Name', size=32, required=True, help='An internal identification of the restaurant floor'),
+        'pos_config_id':    fields.many2one('pos.config','Point of Sale'),
+        'background_image': fields.binary('Background Image', help='A background image used to display a floor layout in the point of sale interface'),  
+        'table_ids':        fields.one2many('restaurant.table','floor_id','Tables', help='The list of tables in this floor'),
+        'sequence':         fields.integer('Sequence',help='Used to sort Floors'),
+    }
+
+    _defaults = {
+        'sequence': 1,
+    }
+
+class restaurant_table(osv.osv):
+    _name = 'restaurant.table'
+    _columns = {
+        'name':         fields.char('Table Name', size=32, required=True, help='An internal identification of a table'),
+        'floor_id':     fields.many2one('restaurant.floor','Floor'),
+        'shape':        fields.selection([('square','Square'),('round','Round')],'Shape', required=True),
+        '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"),
+        '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"),
+        'width':        fields.float('Width', help="The table's width in percentage of the floor's width"),
+        'height':       fields.float('Height', help="The table's height in percentage of the floor's height"),
+        'color':        fields.char('Color', size=32, help="The table's color"),
+        'active':       fields.boolean('Active',help='If false, the table is deactivated and will not be available in the point of sale'),
+        'pos_order_ids':fields.one2many('pos.order','table_id','Pos Orders', help='The orders served at this table'),
+    }
+
+    _defaults = {
+        'shape': 'square',
+        'position_h': 10,
+        'position_v': 10,
+        'height': 50,
+        'width':  50,
+        'active': True,
+    }
+
+    def create_from_ui(self, cr, uid, table, context=None):
+        """ 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',False):
+            floor_id = table['floor_id'][0]
+            table['floor_id'] = floor_id
+
+        if table.get('id',False):   # Modifiy existing table
+            table_id = table['id']
+            del table['id']
+            self.write(cr, uid, [table_id], table, context=context)
+        else:
+            table_id = self.create(cr, uid, table, context=context)
+
+        return table_id
+
 class restaurant_printer(osv.osv):
     _name = 'restaurant.printer'
 
@@ -46,6 +103,8 @@ class pos_config(osv.osv):
     _columns = {
         'iface_splitbill': fields.boolean('Bill Splitting', help='Enables Bill Splitting in the Point of Sale'),
         'iface_printbill': fields.boolean('Bill Printing', help='Allows to print the Bill before payment'),
+        'iface_orderline_notes': fields.boolean('Orderline Notes', help='Allow custom notes on Orderlines'),
+        'floor_ids':       fields.one2many('restaurant.floor','pos_config_id','Restaurant Floors', help='The restaurant floors served by this point of sale'),
         'printer_ids':     fields.many2many('restaurant.printer','pos_config_printer_rel', 'config_id','printer_id',string='Order Printers'),
     }
     _defaults = {
@@ -53,3 +112,9 @@ class pos_config(osv.osv):
         'iface_printbill': False,
     }
             
+class pos_order(osv.osv):
+    _inherit = 'pos.order'
+    _columns = {
+        'table_id': fields.many2one('restaurant.table','Table', help='The table where this order was served'),
+    }
+