From 1c262c2df0178ed9474c1d921d035a4251e41094 Mon Sep 17 00:00:00 2001 From: kame-odoo Date: Wed, 30 Apr 2025 12:21:47 +0530 Subject: [PATCH 1/2] [ADD] filter_appointment: add filter dropdowns to calendar topbar Added a new module named filter_appointment. This module extends the website_calendar_index_topbar template to include filter dropdowns for appointments. The filters allow users to refine results based on payment type, appointment type (online/offline) and availability (user or resource). This enhances the user experience by making it easier to find suitable appointments. --- filter_appointment/__init__.py | 1 + filter_appointment/__manifest__.py | 12 +++++++++ filter_appointment/controllers/__init__.py | 1 + filter_appointment/controllers/appointment.py | 9 +++++++ .../views/appointment_template.xml | 26 +++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 filter_appointment/__init__.py create mode 100644 filter_appointment/__manifest__.py create mode 100644 filter_appointment/controllers/__init__.py create mode 100644 filter_appointment/controllers/appointment.py create mode 100644 filter_appointment/views/appointment_template.xml diff --git a/filter_appointment/__init__.py b/filter_appointment/__init__.py new file mode 100644 index 00000000000..e046e49fbe2 --- /dev/null +++ b/filter_appointment/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/filter_appointment/__manifest__.py b/filter_appointment/__manifest__.py new file mode 100644 index 00000000000..efdff228ca8 --- /dev/null +++ b/filter_appointment/__manifest__.py @@ -0,0 +1,12 @@ +{ + 'name': 'Website Appointment Filters', + 'version': '1.0', + 'summary': 'Add filters to appointment page on website', + 'author': 'kame', + 'depends': ['website', 'appointment'], + 'data': [ + 'views/appointment_template.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/filter_appointment/controllers/__init__.py b/filter_appointment/controllers/__init__.py new file mode 100644 index 00000000000..669664c2844 --- /dev/null +++ b/filter_appointment/controllers/__init__.py @@ -0,0 +1 @@ +from . import appointment diff --git a/filter_appointment/controllers/appointment.py b/filter_appointment/controllers/appointment.py new file mode 100644 index 00000000000..dc463742b82 --- /dev/null +++ b/filter_appointment/controllers/appointment.py @@ -0,0 +1,9 @@ +from odoo import http +from odoo.http import request + + +class WebsiteAppointment(http.Controller): + + @http.route('/appointments', type='http', auth="public", website=True) + def website_appointments(self, **kwargs): + domain = [] diff --git a/filter_appointment/views/appointment_template.xml b/filter_appointment/views/appointment_template.xml new file mode 100644 index 00000000000..d51b7d3b12f --- /dev/null +++ b/filter_appointment/views/appointment_template.xml @@ -0,0 +1,26 @@ + + + From 114a9e323f097b72607b1a920fbf64d2a0a3ad39 Mon Sep 17 00:00:00 2001 From: kame-odoo Date: Fri, 2 May 2025 17:24:06 +0530 Subject: [PATCH 2/2] [IMP] filter_appointment: extend appointment listing with filter options This commit customizes the appointment_type_index route to introduce new filtering options for appointments on the website. Users can now filter appointments based on: Online or offline location () Whether a payment step is required () Whether scheduling is based on users or resources () --- filter_appointment/__manifest__.py | 1 + filter_appointment/controllers/appointment.py | 48 +++++++++++++++++-- .../views/appointment_template.xml | 42 ++++++++-------- 3 files changed, 66 insertions(+), 25 deletions(-) diff --git a/filter_appointment/__manifest__.py b/filter_appointment/__manifest__.py index efdff228ca8..aadd74c12fe 100644 --- a/filter_appointment/__manifest__.py +++ b/filter_appointment/__manifest__.py @@ -9,4 +9,5 @@ ], 'installable': True, 'application': False, + 'license': 'LGPL-3', } diff --git a/filter_appointment/controllers/appointment.py b/filter_appointment/controllers/appointment.py index dc463742b82..455a0e50ee6 100644 --- a/filter_appointment/controllers/appointment.py +++ b/filter_appointment/controllers/appointment.py @@ -1,9 +1,49 @@ from odoo import http +from odoo.addons.website_appointment.controllers.appointment import WebsiteAppointment from odoo.http import request -class WebsiteAppointment(http.Controller): +class WebsiteAppointmentFilter(WebsiteAppointment): - @http.route('/appointments', type='http', auth="public", website=True) - def website_appointments(self, **kwargs): - domain = [] + @http.route() + def appointment_type_index(self, page=1, **kwargs): + filter_domain = [] + + if kwargs.get("appointment_type"): + if kwargs["appointment_type"] == "online": + filter_domain.append(("location_id", "=", False)) + elif kwargs["appointment_type"] == "offline": + filter_domain.append(("location_id", "!=", False)) + + if kwargs.get("payment_step"): + if kwargs["payment_step"] == "required": + filter_domain.append(("has_payment_step", "=", True)) + elif kwargs["payment_step"] == "not_required": + filter_domain.append(("has_payment_step", "=", False)) + + if kwargs.get("schedule_based_on"): + if kwargs["schedule_based_on"] == "users": + filter_domain.append(("schedule_based_on", "=", "users")) + elif kwargs["schedule_based_on"] == "resources": + filter_domain.append(("schedule_based_on", "=", "resources")) + + domain = self._appointments_base_domain( + filter_appointment_type_ids=kwargs.get('filter_appointment_type_ids'), + search=kwargs.get('search'), + additional_domain=filter_domain + ) + + available_appointment_types = self._fetch_and_check_private_appointment_types( + kwargs.get('filter_appointment_type_ids'), + kwargs.get('filter_staff_user_ids'), + kwargs.get('filter_resource_ids'), + kwargs.get('invite_token'), + domain=domain + ) + + return request.render( + 'website_appointment.appointments_cards_layout', + self._prepare_appointments_cards_data( + page, available_appointment_types, **kwargs + ) + ) diff --git a/filter_appointment/views/appointment_template.xml b/filter_appointment/views/appointment_template.xml index d51b7d3b12f..1dbeb052b61 100644 --- a/filter_appointment/views/appointment_template.xml +++ b/filter_appointment/views/appointment_template.xml @@ -1,26 +1,26 @@ -