From 36d36b587940c105a3b7ecdb7a698efcfcb8a896 Mon Sep 17 00:00:00 2001 From: Cybrosys Technologies Date: Thu, 17 Jul 2025 12:38:54 +0530 Subject: [PATCH] July 17: [FIX] Bug Fixed 'odoo_website_helpdesk' --- odoo_website_helpdesk/__manifest__.py | 2 +- odoo_website_helpdesk/controller/website.py | 36 +++++++++++++++------ odoo_website_helpdesk/doc/RELEASE_NOTES.md | 5 +++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/odoo_website_helpdesk/__manifest__.py b/odoo_website_helpdesk/__manifest__.py index 40945a587..c505d02df 100644 --- a/odoo_website_helpdesk/__manifest__.py +++ b/odoo_website_helpdesk/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': "Website Helpdesk Support Ticket Management", - 'version': '16.0.3.0.2', + 'version': '16.0.3.0.3', 'category': 'Website', 'summary': """Helpdesk Module for community""", 'description': 'Can create ticket from website also and can manage it from' diff --git a/odoo_website_helpdesk/controller/website.py b/odoo_website_helpdesk/controller/website.py index 22b04447e..722e1d753 100644 --- a/odoo_website_helpdesk/controller/website.py +++ b/odoo_website_helpdesk/controller/website.py @@ -30,6 +30,7 @@ from odoo.addons.website.controllers.form import WebsiteForm class HelpdeskProduct(http.Controller): """It controls the website products and return the product.""" + @http.route('/product', auth='public', type='json') def product(self): """Product control function""" @@ -45,6 +46,7 @@ class WebsiteFormInherit(WebsiteForm): controller to display a list of tickets for the current user in their portal, and overrides the website form controller's method for handling form submissions to create a new help desk ticket instead.""" + def _handle_website_form(self, model_name, **kwargs): """Website Help Desk Form""" if model_name == 'help.ticket': @@ -56,12 +58,28 @@ class WebsiteFormInherit(WebsiteForm): if rec == lowest_sequence: lowest_stage_id = lowest_sequence products = kwargs.get('product') - partner_create = request.env['res.partner'].sudo().create({ - 'name':kwargs.get('customer_name'), - 'company_name':kwargs.get('company'), - 'phone':kwargs.get('phone'), - 'email':kwargs.get('email_from') - }) + + # Check if user is logged in and not public user + if request.env.user and request.env.user.id != request.env.ref( + 'base.public_user').id: + partner_create = request.env.user.partner_id + else: + # Check if partner already exists with the same email + email = kwargs.get('email_from') + existing_partner = request.env['res.partner'].sudo().search([ + ('email', '=', email) + ], limit=1) + if existing_partner: + partner_create = existing_partner + else: + # Create new partner only if it doesn't exist + partner_create = request.env['res.partner'].sudo().create({ + 'name': kwargs.get('customer_name'), + 'company_name': kwargs.get('company'), + 'phone': kwargs.get('phone'), + 'email': kwargs.get('email_from') + }) + if products: splited_product = products.split(',') product_list = [int(i) for i in splited_product] @@ -86,7 +104,7 @@ class WebsiteFormInherit(WebsiteForm): data = self.extract_data(model_record, request.params) if ('ticket_attachment' in request.params or request.httprequest.files or data.get( - 'attachments')): + 'attachments')): attached_files = data.get('attachments') for attachment in attached_files: attached_file = attachment.read() @@ -122,7 +140,7 @@ class WebsiteFormInherit(WebsiteForm): data = self.extract_data(model_record, request.params) if ('ticket_attachment' in request.params or request.httprequest.files or data.get( - 'attachments')): + 'attachments')): attached_files = data.get('attachments') for attachment in attached_files: attached_file = attachment.read() @@ -185,4 +203,4 @@ class WebsiteFormInherit(WebsiteForm): request.session['form_builder_model_model'] = model_record.model request.session['form_builder_model'] = model_record.name request.session['form_builder_id'] = id_record - return json.dumps({'id': id_record}) + return json.dumps({'id': id_record}) \ No newline at end of file diff --git a/odoo_website_helpdesk/doc/RELEASE_NOTES.md b/odoo_website_helpdesk/doc/RELEASE_NOTES.md index 2329976ba..4eb3c6965 100644 --- a/odoo_website_helpdesk/doc/RELEASE_NOTES.md +++ b/odoo_website_helpdesk/doc/RELEASE_NOTES.md @@ -15,3 +15,8 @@ #### Version 16.0.3.0.2 ##### UPDT -A confirmation email will be sent to the customer upon ticket creation. + +#### 14.07.2025 +#### Version 16.0.3.0.3 +##### FIX +- Tickets created was not visible for the user.