From b61b3da89eee313c2fbaa04263213ac7dc0aaaee Mon Sep 17 00:00:00 2001 From: RisvanaCybro Date: Wed, 19 Jun 2024 11:44:54 +0530 Subject: [PATCH] Jun 19: [FIX] Bug Fixed 'table_reservation_on_website' --- table_reservation_on_website/__manifest__.py | 2 +- .../controllers/table_reservation_on_website.py | 16 +++++++--------- .../doc/RELEASE_NOTES.md | 7 ++++++- .../models/table_reservation.py | 3 +-- .../static/src/js/PaymentScreen.js | 10 ---------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/table_reservation_on_website/__manifest__.py b/table_reservation_on_website/__manifest__.py index 49b8896f1..e84598766 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': '17.0.1.0.1', + 'version': '17.0.1.0.2', 'category': 'eCommerce,Point of Sale', 'summary': 'Reserve tables in POS from website', 'description': """This module enables to reserve tables in POS from website. 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 a58cc15c4..2036f388a 100644 --- a/table_reservation_on_website/controllers/table_reservation_on_website.py +++ b/table_reservation_on_website/controllers/table_reservation_on_website.py @@ -35,7 +35,7 @@ class TableReservation(http.Controller): @http.route(['/restaurant/floors'], type='http', auth='user', website=True) def restaurant_floors(self, **kwargs): """ To get floor details """ - floors = request.env['restaurant.floor'].search([]) + floors = request.env['restaurant.floor'].sudo().search([]) payment = request.env['ir.config_parameter'].sudo().get_param( "table_reservation_on_website.reservation_charge") refund = request.env['ir.config_parameter'].sudo().get_param( @@ -58,9 +58,9 @@ class TableReservation(http.Controller): table_inbetween = [] payment = request.env['ir.config_parameter'].sudo().get_param( "table_reservation_on_website.reservation_charge") - tables = request.env['restaurant.table'].search( + tables = request.env['restaurant.table'].sudo().search( [('floor_id', '=', int(kwargs.get('floors_id')))]) - reserved = request.env['table.reservation'].search( + reserved = request.env['table.reservation'].sudo().search( [('floor_id', '=', int(kwargs.get('floors_id'))), ( 'date', '=', datetime.strptime(kwargs.get('date'), "%Y-%m-%d")), ( @@ -95,7 +95,7 @@ class TableReservation(http.Controller): """ For booking tables """ company = request.env.company list_tables = [rec for rec in kwargs.get("tables").split(',')] - record_tables = request.env['restaurant.table'].search( + record_tables = request.env['restaurant.table'].sudo().search( [('id', 'in', list_tables)]) amount = [rec.rate for rec in record_tables] payment = request.env['ir.config_parameter'].sudo().get_param( @@ -130,7 +130,7 @@ class TableReservation(http.Controller): 'price_unit': sum(amount), })], }) - sale_order.website_id = request.env['website'].search( + sale_order.website_id = request.env['website'].sudo().search( [('company_id', '=', company.id)], limit=1) return request.redirect("/shop/cart") else: @@ -149,9 +149,9 @@ class TableReservation(http.Controller): @http.route(['/table/reservation/pos'], type='json', auth='user', website=True) - def table_reservation_pos(self, partner_id, table_id): + def table_reservation_pos(self, table_id): """ For pos table booking """ - table = request.env['restaurant.table'].browse(table_id) + table = request.env['restaurant.table'].sudo().browse(table_id) date_and_time = datetime.now() starting_at = ( (date_and_time + timedelta(hours=5, minutes=30)).time()).strftime( @@ -163,7 +163,6 @@ class TableReservation(http.Controller): "table_reservation_on_website.reservation_charge") if payment: request.env['table.reservation'].sudo().create({ - 'customer_id': partner_id, 'floor_id': table.floor_id.id, 'booked_tables_ids': table, 'date': date_and_time.date(), @@ -174,7 +173,6 @@ class TableReservation(http.Controller): }) else: request.env['table.reservation'].sudo().create({ - 'customer_id': partner_id, 'floor_id': table.floor_id.id, 'booked_tables_ids': table, 'date': date_and_time.date(), diff --git a/table_reservation_on_website/doc/RELEASE_NOTES.md b/table_reservation_on_website/doc/RELEASE_NOTES.md index d3728cac3..c635f7872 100644 --- a/table_reservation_on_website/doc/RELEASE_NOTES.md +++ b/table_reservation_on_website/doc/RELEASE_NOTES.md @@ -8,4 +8,9 @@ #### 27.05.2024 #### Version 17.0.1.0.1 ##### UPDT -- Issue solved on the pos payment screen. \ No newline at end of file +- Issue solved on the pos payment screen. + +#### 19.06.2024 +#### Version 17.0.1.0.1 +##### BUGFIX +- Fixed issues in table booking from website. diff --git a/table_reservation_on_website/models/table_reservation.py b/table_reservation_on_website/models/table_reservation.py index f7da0bdae..7a44599ff 100644 --- a/table_reservation_on_website/models/table_reservation.py +++ b/table_reservation_on_website/models/table_reservation.py @@ -35,8 +35,7 @@ class TableReservation(models.Model): copy=False, help="Sequence number for records") customer_id = fields.Many2one(comodel_name="res.partner", string="Customer", - help="Name of the customer", - required=True) + help="Name of the customer") floor_id = fields.Many2one(comodel_name='restaurant.floor', string="Floor Plan", help="Booked floor", required=True) diff --git a/table_reservation_on_website/static/src/js/PaymentScreen.js b/table_reservation_on_website/static/src/js/PaymentScreen.js index e3f2d4e1b..6ffba1a14 100644 --- a/table_reservation_on_website/static/src/js/PaymentScreen.js +++ b/table_reservation_on_website/static/src/js/PaymentScreen.js @@ -10,19 +10,9 @@ patch(PaymentScreen.prototype, { For payment validation in pos **/ async _finalizeValidation() { - let customer = this.currentOrder.get_partner(); - if (!customer){ - await this.popup.add(ConfirmPopup, { - title: _t("Customer Required"), - body: _t("Customer is required."), - }) - } - else{ jsonrpc('/table/reservation/pos',{ - 'partner_id' : customer.id, 'table_id': this.currentOrder.tableId }).then( function(data){}) return super._finalizeValidation() } - } });