diff --git a/table_reservation_on_website/__manifest__.py b/table_reservation_on_website/__manifest__.py index bc4351719..55abc214d 100644 --- a/table_reservation_on_website/__manifest__.py +++ b/table_reservation_on_website/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': 'Table Reservation on Website', - 'version': '16.0.1.0.1', + 'version': '16.0.1.1.1', 'category': 'eCommerce,Point of Sale', 'summary': 'We can reserve table through website', 'description': 'We can reserve table through website. And also user can ' @@ -53,6 +53,7 @@ 'web.assets_frontend': [ 'table_reservation_on_website/static/src/js/table_reservation.js', 'table_reservation_on_website/static/src/js/reservation_floor.js', + 'table_reservation_on_website/static/src/js/reservation.js', ], }, 'images': ['static/description/banner.jpg'], diff --git a/table_reservation_on_website/controllers/__init__.py b/table_reservation_on_website/controllers/__init__.py index 4b23b6364..8e50fbc75 100644 --- a/table_reservation_on_website/controllers/__init__.py +++ b/table_reservation_on_website/controllers/__init__.py @@ -21,3 +21,4 @@ ############################################################################### from . import main from . import table_reservation_on_website +from . import pos_config diff --git a/table_reservation_on_website/controllers/pos_config.py b/table_reservation_on_website/controllers/pos_config.py new file mode 100644 index 000000000..26ca58c6f --- /dev/null +++ b/table_reservation_on_website/controllers/pos_config.py @@ -0,0 +1,29 @@ +from odoo import http +from odoo.http import request + + +class ResConfigSettingsController(http.Controller): + + @http.route('/pos/get_opening_closing_hours', type='json', auth='public', methods=['POST']) + def get_opening_closing_hours(self): + res_config = request.env['res.config.settings'].sudo().search([], limit=1, order="id desc") + # Ensure proper time format + try: + opening_hour = self.float_to_time(float(res_config.opening_hour)) + closing_hour = self.float_to_time(float(res_config.closing_hour)) + except ValueError: + opening_hour = "00:00" + closing_hour = "23:59" + + if res_config: + return { + 'opening_hour': opening_hour, + 'closing_hour': closing_hour + } + return {'error': 'POS configuration not found'} + + def float_to_time(self, hour_float): + """ Convert float hours (e.g., 8.5 → 08:30) to HH:MM format """ + hours = int(hour_float) + minutes = int((hour_float - hours) * 60) + return f"{hours:02d}:{minutes:02d}" diff --git a/table_reservation_on_website/controllers/table_reservation_on_website.py b/table_reservation_on_website/controllers/table_reservation_on_website.py index 4ab1753d5..0b41e948d 100644 --- a/table_reservation_on_website/controllers/table_reservation_on_website.py +++ b/table_reservation_on_website/controllers/table_reservation_on_website.py @@ -30,8 +30,26 @@ class TableReservation(http.Controller): @http.route(['/table_reservation'], type='http', auth='user', website=True) def table_reservation(self): """For render table reservation template""" + pos_config = request.env['res.config.settings'].sudo().search([], + limit=1, order="id desc") + try: + opening_hour = self.float_to_time( + float(pos_config.opening_hour)) + closing_hour = self.float_to_time( + float(pos_config.closing_hour)) + except ValueError: + opening_hour = "00:00" + closing_hour = "23:59" return http.request.render( - "table_reservation_on_website.table_reservation", {}) + "table_reservation_on_website.table_reservation", + {'opening_hour': opening_hour, + 'closing_hour': closing_hour}) + + def float_to_time(self, hour_float): + """ Convert float hours (e.g., 8.5 → 08:30) to HH:MM format """ + hours = int(hour_float) + minutes = int((hour_float - hours) * 60) + return f"{hours:02d}:{minutes:02d}" @http.route(['/restaurant/floors'], type='http', auth='user', website=True) def restaurant_floors(self, **kwargs): diff --git a/table_reservation_on_website/doc/RELEASE_NOTES.md b/table_reservation_on_website/doc/RELEASE_NOTES.md index f2e3f3d79..ef33478eb 100644 --- a/table_reservation_on_website/doc/RELEASE_NOTES.md +++ b/table_reservation_on_website/doc/RELEASE_NOTES.md @@ -5,3 +5,10 @@ #### ADD - Initial commit for Table Reservation on Website + +#### 29.03.2025 +#### Version 16.0.1.1.1 +#### UPDATE + +- Updated module to set opening and closing hours. + diff --git a/table_reservation_on_website/models/res_config_settings.py b/table_reservation_on_website/models/res_config_settings.py index 7d2ea6f27..91207c536 100644 --- a/table_reservation_on_website/models/res_config_settings.py +++ b/table_reservation_on_website/models/res_config_settings.py @@ -34,17 +34,40 @@ class ResConfigSettings(models.TransientModel): "_charge") refund = fields.Text(string="No Refund Notes", help="No refund notes to " "display in website") + set_opening_hours = fields.Boolean(string="Set Opening Hours", + help="Enable to configure restaurant opening and closing hours.", + config_parameter="table_" + "reservation_on_" + "website.reservation" + "set_opening_hours") + opening_hour = fields.Float(string="Opening Hours", + help="Restaurant opening hour in 24-hour format." + ) + closing_hour = fields.Float(string="Closing Hours", + help="Restaurant closing hour in 24-hour format." + ) def set_values(self): """To set the value for a fields in config setting""" - self.env['ir.config_parameter'].set_param( - 'table_reservation_on_website.refund', self.refund) - return super(ResConfigSettings, self).set_values() + """To set the value for fields in config setting""" + super(ResConfigSettings, self).set_values() + params = self.env['ir.config_parameter'].sudo() + params.set_param('table_reservation_on_website.refund', + self.refund or "") + params.set_param('table_reservation_on_website.opening_hour', + self.opening_hour or 0.0) + params.set_param('table_reservation_on_website.closing_hour', + self.closing_hour or 0.0) def get_values(self): - """To get the value in config settings""" + """To get the values in config settings""" res = super(ResConfigSettings, self).get_values() - refund = self.env['ir.config_parameter'].sudo().get_param( - 'table_reservation_on_website.refund') - res.update(refund=refund if refund else False) + params = self.env['ir.config_parameter'].sudo() + + res.update( + refund=params.get_param('table_reservation_on_website.refund', ""), + opening_hour=float(params.get_param('table_reservation_on_website.opening_hour', 0.0)), + closing_hour=float(params.get_param('table_reservation_on_website.closing_hour', 0.0)) + ) return res + diff --git a/table_reservation_on_website/static/description/assets/screenshots/1.png b/table_reservation_on_website/static/description/assets/screenshots/1.png index 74413ab25..740dd7ad1 100644 Binary files a/table_reservation_on_website/static/description/assets/screenshots/1.png and b/table_reservation_on_website/static/description/assets/screenshots/1.png differ diff --git a/table_reservation_on_website/static/description/assets/screenshots/11.png b/table_reservation_on_website/static/description/assets/screenshots/11.png index a7d21a05f..4b46f1bdf 100644 Binary files a/table_reservation_on_website/static/description/assets/screenshots/11.png and b/table_reservation_on_website/static/description/assets/screenshots/11.png differ diff --git a/table_reservation_on_website/static/description/assets/screenshots/4.png b/table_reservation_on_website/static/description/assets/screenshots/4.png index 1228a3a42..ef15c6619 100644 Binary files a/table_reservation_on_website/static/description/assets/screenshots/4.png and b/table_reservation_on_website/static/description/assets/screenshots/4.png differ diff --git a/table_reservation_on_website/static/description/index.html b/table_reservation_on_website/static/description/index.html index 04b98b799..47e3ac3c2 100644 --- a/table_reservation_on_website/static/description/index.html +++ b/table_reservation_on_website/static/description/index.html @@ -172,7 +172,7 @@
If we enable "Reservation Charge" we want to pay for reservation. If we disable "Reservation Charge" there is - no payment for table reservation.
+ no payment for table reservation. Also set opening and closing hours for table reservation.