Browse Source

Jan 27: [FIX] Bug Fixed 'salon_management'

pull/309/head
Cybrosys Technologies 6 months ago
parent
commit
30b16d727f
  1. 2
      salon_management/__manifest__.py
  2. 31
      salon_management/controllers/salon_management.py
  3. 6
      salon_management/doc/RELEASE_NOTES.md
  4. 18
      salon_management/models/salon_booking.py
  5. 3
      salon_management/static/src/js/website_salon_booking.js
  6. 7
      salon_management/static/src/xml/salon_dashboard.xml

2
salon_management/__manifest__.py

@ -21,7 +21,7 @@
################################################################################ ################################################################################
{ {
'name': 'Beauty Spa Management', 'name': 'Beauty Spa Management',
'version': '17.0.1.0.0', 'version': '17.0.1.1.0',
"category": "Services", "category": "Services",
'summary': 'Beauty Parlour Management with Online Booking System', 'summary': 'Beauty Parlour Management with Online Booking System',
'description': 'This module to helps your customers to do the online ' 'description': 'This module to helps your customers to do the online '

31
salon_management/controllers/salon_management.py

@ -39,7 +39,11 @@ class SalonBookingWeb(http.Controller):
service_list.append(int(val)) service_list.append(int(val))
val += 1 val += 1
dates_time = date + " " + salon_time + ":00" dates_time = date + " " + salon_time + ":00"
date_and_time = (pytz.timezone(request.env.user.tz).localize( user_tz = request.env.user.tz or 'UTC'
if isinstance(user_tz, bool):
user_tz = 'UTC' # Ensure it's a string
local_tz = pytz.timezone(user_tz)
date_and_time = (local_tz.localize(
datetime.strptime(str(dates_time), '%Y-%m-%d %H:%M:%S')). datetime.strptime(str(dates_time), '%Y-%m-%d %H:%M:%S')).
astimezone(pytz.UTC).replace(tzinfo=None)) astimezone(pytz.UTC).replace(tzinfo=None))
a = request.env['salon.booking'].create({ a = request.env['salon.booking'].create({
@ -58,10 +62,14 @@ class SalonBookingWeb(http.Controller):
website=True) website=True)
def salon_check(self, **kwargs): def salon_check(self, **kwargs):
year, month, day = map(int, kwargs['check_date'].split('-')) year, month, day = map(int, kwargs['check_date'].split('-'))
date_start = pytz.timezone(request.env.user.tz).localize( user_tz = request.env.user.tz or 'UTC'
if isinstance(user_tz, bool):
user_tz = 'UTC' # Ensure it's a string
local_tz = pytz.timezone(user_tz)
date_start = local_tz.localize(
datetime(year, month, day, hour=0, minute=0, second=0)).astimezone( datetime(year, month, day, hour=0, minute=0, second=0)).astimezone(
pytz.UTC).replace(tzinfo=None) pytz.UTC).replace(tzinfo=None)
date_end = (pytz.timezone(request.env.user.tz). date_end = (local_tz.
localize(datetime(year, month, day, hour=23, minute=59, localize(datetime(year, month, day, hour=23, minute=59,
second=59)).astimezone(pytz.UTC). second=59)).astimezone(pytz.UTC).
replace(tzinfo=None)) replace(tzinfo=None))
@ -74,11 +82,9 @@ class SalonBookingWeb(http.Controller):
data = { data = {
'number': order.id, 'number': order.id,
'start_time_only': fields.Datetime.to_string(pytz.UTC.localize( 'start_time_only': fields.Datetime.to_string(pytz.UTC.localize(
order.start_time).astimezone(pytz.timezone( order.start_time).astimezone(local_tz).replace(tzinfo=None))[11:16],
request.env.user.tz)).replace(tzinfo=None))[11:16],
'end_time_only': fields.Datetime.to_string(pytz.UTC.localize( 'end_time_only': fields.Datetime.to_string(pytz.UTC.localize(
order.end_time).astimezone(pytz.timezone( order.end_time).astimezone(local_tz).replace(tzinfo=None))[11:16],
request.env.user.tz)).replace(tzinfo=None))[11:16],
} }
if order.chair_id.id not in order_details: if order.chair_id.id not in order_details:
order_details[order.chair_id.id] = { order_details[order.chair_id.id] = {
@ -104,10 +110,13 @@ class SalonBookingWeb(http.Controller):
salon_holiday_obj = request.env['salon.holiday'].search( salon_holiday_obj = request.env['salon.holiday'].search(
[('holiday', '=', True)]) [('holiday', '=', True)])
date_check = datetime.today().date() date_check = datetime.today().date()
date_start = (pytz.timezone(request.env.user.tz).localize( user_tz = request.env.user.tz or 'UTC'
datetime.combine(date_check, time(hour=0, minute=0, second=0))). if isinstance(user_tz, bool):
astimezone(pytz.UTC).replace(tzinfo=None)) user_tz = 'UTC' # Ensure it's a string
date_end = (pytz.timezone(request.env.user.tz).localize( local_tz = pytz.timezone(user_tz)
date_start = local_tz.localize(datetime.combine(date_check, time(hour=0, minute=0, second=0))).astimezone(
pytz.UTC).replace(tzinfo=None)
date_end = (local_tz.localize(
datetime.combine(date_check, time(hour=23, minute=59, second=59))). datetime.combine(date_check, time(hour=23, minute=59, second=59))).
astimezone(pytz.UTC).replace(tzinfo=None)) astimezone(pytz.UTC).replace(tzinfo=None))
# chair_obj = # chair_obj =

6
salon_management/doc/RELEASE_NOTES.md

@ -5,3 +5,9 @@
#### ADD #### ADD
- Initial commit for Beauty Spa Management - Initial commit for Beauty Spa Management
#### 21.01.2025
#### Version 17.0.1.1.0
#### UPDT
- Fixed bugs in salon module

18
salon_management/models/salon_booking.py

@ -79,21 +79,23 @@ class SalonBooking(models.Model):
def action_approve_booking(self): def action_approve_booking(self):
"""Approve the booking for salon services""" """Approve the booking for salon services"""
salon_order = self.env['salon.order'].create(
{'customer_name': self.name,
'chair_id': self.chair_id.id,
'start_time': self.time,
'date': fields.Datetime.now(),
'stage_id': 1,
'booking_identifier': True})
for service in self.service_ids: for service in self.service_ids:
self.env['salon.order.line'].create({ self.env['salon.order.line'].create({
'service_id': service.id, 'service_id': service.id,
'time_taken': service.time_taken, 'time_taken': service.time_taken,
'price': service.price, 'price': service.price,
'price_subtotal': service.price, 'price_subtotal': service.price,
'salon_order_id': self.env['salon.order'].create( 'salon_order_id': salon_order.id,
{'customer_name': self.name,
'chair_id': self.chair_id.id,
'start_time': self.time,
'date': fields.Datetime.now(),
'stage_id': 1,
'booking_identifier': True}).id,
}) })
self.env['mail.template'].browse(self.env.ref(
mail = self.env['mail.template'].browse(self.env.ref(
'salon_management.mail_template_salon_approved').id).send_mail( 'salon_management.mail_template_salon_approved').id).send_mail(
self.id, force_send=True) self.id, force_send=True)
self.state = "approved" self.state = "approved"

3
salon_management/static/src/js/website_salon_booking.js

@ -60,6 +60,7 @@ publicWidget.registry.SalonManagement = publicWidget.Widget.extend({
}, },
/** Website function to check already booked chairs and details **/ /** Website function to check already booked chairs and details **/
ClickCheckButton(ev){ ClickCheckButton(ev){
console.log("ClickCheckButton")
var check_date = this.$el.find("#check_date").val(); var check_date = this.$el.find("#check_date").val();
if (check_date != "") { if (check_date != "") {
jsonrpc('/page/salon_check_date', { jsonrpc('/page/salon_check_date', {
@ -71,6 +72,7 @@ publicWidget.registry.SalonManagement = publicWidget.Widget.extend({
var chair_name; var chair_name;
for (x in order_details) { for (x in order_details) {
var chair_name = order_details[x]['name'] var chair_name = order_details[x]['name']
console.log("chair_name:", chair_name)
var i; var i;
var lines = ""; var lines = "";
for (i = 0; i < order_details[x]['orders'].length; i++) { for (i = 0; i < order_details[x]['orders'].length; i++) {
@ -96,6 +98,7 @@ publicWidget.registry.SalonManagement = publicWidget.Widget.extend({
date_field.innerHTML = ""; date_field.innerHTML = "";
date_field.innerHTML = date_value; date_field.innerHTML = date_value;
}) })
} else { } else {
alert("Fill the Field"); alert("Fill the Field");
} }

7
salon_management/static/src/xml/salon_dashboard.xml

@ -75,11 +75,10 @@
</div> </div>
</div> </div>
<!-- Dashboard chairs view--> <!-- Dashboard chairs view-->
<article role="main" id="chairs_dashboard_view"> <article role="main" id="chairs_dashboard_view" t-ref="chairs_dashboard_view">
<t t-foreach="this.state.list" t-as="chair" t-key="chair"> <t t-foreach="this.state.list" t-as="chair" t-key="chair.id">
<div class="salon_chair" t-att-id="chair['id']" <div class="salon_chair" t-att-id="chair['id']"
t-att-value="chair['id']" t-on-click="chairs_click" t-att-value="chair['id']" t-on-click="chairs_click">
t-ref="chairs_dashboard_view">
<h4 class="chair_name" t-att-id="chair['id']"> <h4 class="chair_name" t-att-id="chair['id']">
<t t-esc="chair['name']"/> <t t-esc="chair['name']"/>
</h4> </h4>

Loading…
Cancel
Save