30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from odoo import models, fields, api
|
|
|
|
class RestaurantTable(models.Model):
|
|
_inherit = 'restaurant.table'
|
|
|
|
is_reservation_enabled = fields.Boolean(string='Enabled for Reservation', default=True)
|
|
min_party_size = fields.Integer(string='Min Party Size', default=1)
|
|
max_party_size = fields.Integer(string='Max Party Size', default=1)
|
|
zone = fields.Char(string='Zone/Section', help="e.g. Window Side, Garden, VIP Section")
|
|
reservation_slot_duration = fields.Selection([
|
|
('0.5', '30 Minutes'),
|
|
('1.0', '1 Hour'),
|
|
('1.5', '1.5 Hours'),
|
|
('2.0', '2 Hours'),
|
|
('3.0', '3 Hours'),
|
|
], string='Slot Duration', default='1.0', required=True)
|
|
|
|
@api.onchange('seats')
|
|
def _onchange_seats_for_reservation(self):
|
|
for record in self:
|
|
if record.seats == 6:
|
|
record.min_party_size = 4
|
|
record.max_party_size = 6
|
|
elif record.seats == 4:
|
|
record.min_party_size = 2
|
|
record.max_party_size = 4
|
|
else:
|
|
record.min_party_size = 1
|
|
record.max_party_size = record.seats or 1
|