Browse Source

Jun 19: [FIX] Bug Fixed 'table_reservation_on_website'

pull/331/head
RisvanaCybro 12 months ago
parent
commit
b61b3da89e
  1. 2
      table_reservation_on_website/__manifest__.py
  2. 16
      table_reservation_on_website/controllers/table_reservation_on_website.py
  3. 5
      table_reservation_on_website/doc/RELEASE_NOTES.md
  4. 3
      table_reservation_on_website/models/table_reservation.py
  5. 10
      table_reservation_on_website/static/src/js/PaymentScreen.js

2
table_reservation_on_website/__manifest__.py

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
{ {
'name': 'Table Reservation on Website', 'name': 'Table Reservation on Website',
'version': '17.0.1.0.1', 'version': '17.0.1.0.2',
'category': 'eCommerce,Point of Sale', 'category': 'eCommerce,Point of Sale',
'summary': 'Reserve tables in POS from website', 'summary': 'Reserve tables in POS from website',
'description': """This module enables to reserve tables in POS from website. 'description': """This module enables to reserve tables in POS from website.

16
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) @http.route(['/restaurant/floors'], type='http', auth='user', website=True)
def restaurant_floors(self, **kwargs): def restaurant_floors(self, **kwargs):
""" To get floor details """ """ 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( payment = request.env['ir.config_parameter'].sudo().get_param(
"table_reservation_on_website.reservation_charge") "table_reservation_on_website.reservation_charge")
refund = request.env['ir.config_parameter'].sudo().get_param( refund = request.env['ir.config_parameter'].sudo().get_param(
@ -58,9 +58,9 @@ class TableReservation(http.Controller):
table_inbetween = [] table_inbetween = []
payment = request.env['ir.config_parameter'].sudo().get_param( payment = request.env['ir.config_parameter'].sudo().get_param(
"table_reservation_on_website.reservation_charge") "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')))]) [('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'))), ( [('floor_id', '=', int(kwargs.get('floors_id'))), (
'date', '=', datetime.strptime(kwargs.get('date'), 'date', '=', datetime.strptime(kwargs.get('date'),
"%Y-%m-%d")), ( "%Y-%m-%d")), (
@ -95,7 +95,7 @@ class TableReservation(http.Controller):
""" For booking tables """ """ For booking tables """
company = request.env.company company = request.env.company
list_tables = [rec for rec in kwargs.get("tables").split(',')] 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)]) [('id', 'in', list_tables)])
amount = [rec.rate for rec in record_tables] amount = [rec.rate for rec in record_tables]
payment = request.env['ir.config_parameter'].sudo().get_param( payment = request.env['ir.config_parameter'].sudo().get_param(
@ -130,7 +130,7 @@ class TableReservation(http.Controller):
'price_unit': sum(amount), '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) [('company_id', '=', company.id)], limit=1)
return request.redirect("/shop/cart") return request.redirect("/shop/cart")
else: else:
@ -149,9 +149,9 @@ class TableReservation(http.Controller):
@http.route(['/table/reservation/pos'], type='json', auth='user', @http.route(['/table/reservation/pos'], type='json', auth='user',
website=True) website=True)
def table_reservation_pos(self, partner_id, table_id): def table_reservation_pos(self, table_id):
""" For pos table booking """ """ 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() date_and_time = datetime.now()
starting_at = ( starting_at = (
(date_and_time + timedelta(hours=5, minutes=30)).time()).strftime( (date_and_time + timedelta(hours=5, minutes=30)).time()).strftime(
@ -163,7 +163,6 @@ class TableReservation(http.Controller):
"table_reservation_on_website.reservation_charge") "table_reservation_on_website.reservation_charge")
if payment: if payment:
request.env['table.reservation'].sudo().create({ request.env['table.reservation'].sudo().create({
'customer_id': partner_id,
'floor_id': table.floor_id.id, 'floor_id': table.floor_id.id,
'booked_tables_ids': table, 'booked_tables_ids': table,
'date': date_and_time.date(), 'date': date_and_time.date(),
@ -174,7 +173,6 @@ class TableReservation(http.Controller):
}) })
else: else:
request.env['table.reservation'].sudo().create({ request.env['table.reservation'].sudo().create({
'customer_id': partner_id,
'floor_id': table.floor_id.id, 'floor_id': table.floor_id.id,
'booked_tables_ids': table, 'booked_tables_ids': table,
'date': date_and_time.date(), 'date': date_and_time.date(),

5
table_reservation_on_website/doc/RELEASE_NOTES.md

@ -9,3 +9,8 @@
#### Version 17.0.1.0.1 #### Version 17.0.1.0.1
##### UPDT ##### UPDT
- Issue solved on the pos payment screen. - Issue solved on the pos payment screen.
#### 19.06.2024
#### Version 17.0.1.0.1
##### BUGFIX
- Fixed issues in table booking from website.

3
table_reservation_on_website/models/table_reservation.py

@ -35,8 +35,7 @@ class TableReservation(models.Model):
copy=False, help="Sequence number for records") copy=False, help="Sequence number for records")
customer_id = fields.Many2one(comodel_name="res.partner", customer_id = fields.Many2one(comodel_name="res.partner",
string="Customer", string="Customer",
help="Name of the customer", help="Name of the customer")
required=True)
floor_id = fields.Many2one(comodel_name='restaurant.floor', floor_id = fields.Many2one(comodel_name='restaurant.floor',
string="Floor Plan", string="Floor Plan",
help="Booked floor", required=True) help="Booked floor", required=True)

10
table_reservation_on_website/static/src/js/PaymentScreen.js

@ -10,19 +10,9 @@ patch(PaymentScreen.prototype, {
For payment validation in pos For payment validation in pos
**/ **/
async _finalizeValidation() { 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',{ jsonrpc('/table/reservation/pos',{
'partner_id' : customer.id,
'table_id': this.currentOrder.tableId 'table_id': this.currentOrder.tableId
}).then( function(data){}) }).then( function(data){})
return super._finalizeValidation() return super._finalizeValidation()
} }
}
}); });

Loading…
Cancel
Save