From 784cebad7cff33f2503e2c0d966063dc4247b612 Mon Sep 17 00:00:00 2001 From: Risvana Cybro Date: Sat, 20 Sep 2025 22:47:53 +0530 Subject: [PATCH] Sep 20: [FIX] Bug Fixed 'ecommerce_barcode_search' --- ecommerce_barcode_search/__init__.py | 1 + ecommerce_barcode_search/__manifest__.py | 2 +- .../controllers/web_product_qr_scan.py | 6 ++++- ecommerce_barcode_search/doc/RELEASE_NOTES.md | 5 ++++ ecommerce_barcode_search/models/__init__.py | 2 ++ .../models/product_template.py | 23 +++++++++++++++++++ 6 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 ecommerce_barcode_search/models/__init__.py create mode 100644 ecommerce_barcode_search/models/product_template.py diff --git a/ecommerce_barcode_search/__init__.py b/ecommerce_barcode_search/__init__.py index f98d0b623..5d7dca08a 100644 --- a/ecommerce_barcode_search/__init__.py +++ b/ecommerce_barcode_search/__init__.py @@ -21,3 +21,4 @@ # ################################################################################### from . import controllers +from . import models diff --git a/ecommerce_barcode_search/__manifest__.py b/ecommerce_barcode_search/__manifest__.py index 0c041ee67..c78bb4169 100644 --- a/ecommerce_barcode_search/__manifest__.py +++ b/ecommerce_barcode_search/__manifest__.py @@ -22,7 +22,7 @@ ################################################################################### { 'name': 'Ecommerce Barcode Search', - 'version': '18.0.1.0.0', + 'version': '18.0.1.1.0', 'category': 'Website', 'summary': 'Ecommerce Barcode Search', 'description': 'This module enables users to search for products on the website using barcodes.' diff --git a/ecommerce_barcode_search/controllers/web_product_qr_scan.py b/ecommerce_barcode_search/controllers/web_product_qr_scan.py index cab7a6703..8a58b6bb9 100644 --- a/ecommerce_barcode_search/controllers/web_product_qr_scan.py +++ b/ecommerce_barcode_search/controllers/web_product_qr_scan.py @@ -35,10 +35,14 @@ class WebsiteProductBarcode(WebsiteSale): input_data = kwargs.get('last_code') slug = request.env['ir.http']._slug barcode_product = request.env['product.product'].search([('barcode', '=', input_data)]) + request.session['barcode'] = input_data + request.session['barcode_product'] = barcode_product.id if barcode_product: return { 'type': 'ir.actions.act_url', - 'url': '/shop/%s' % slug(barcode_product.product_tmpl_id) + 'url': '/shop/%s?extra_param=true' % slug(barcode_product.product_tmpl_id) } else: return False + + diff --git a/ecommerce_barcode_search/doc/RELEASE_NOTES.md b/ecommerce_barcode_search/doc/RELEASE_NOTES.md index 32bf8c9ca..6594f58cc 100644 --- a/ecommerce_barcode_search/doc/RELEASE_NOTES.md +++ b/ecommerce_barcode_search/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 18.0.1.0.0 #### ADD - Initial Commit for Ecommerce Barcode Search + +#### 18.09.2025 +#### Version 18.0.1.1.0 +#### BUG_FIX +- Enabled variant selection on the product page via barcode scanning \ No newline at end of file diff --git a/ecommerce_barcode_search/models/__init__.py b/ecommerce_barcode_search/models/__init__.py new file mode 100644 index 000000000..2757b3ab6 --- /dev/null +++ b/ecommerce_barcode_search/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import product_template diff --git a/ecommerce_barcode_search/models/product_template.py b/ecommerce_barcode_search/models/product_template.py new file mode 100644 index 000000000..067cc80f0 --- /dev/null +++ b/ecommerce_barcode_search/models/product_template.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from odoo import models +from odoo.http import request + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + def _get_combination_info( + self, combination=False, product_id=False, add_qty=1.0, + parent_combination=False, only_template=False, is_barcode=False + ): + + res = super()._get_combination_info(combination=combination, product_id=product_id, add_qty=add_qty, + parent_combination=parent_combination, only_template=only_template) + if is_barcode: + if request.session.get('barcode'): + product = self.env['product.product'].search([('barcode', '=', request.session.get('barcode'))]) + if product: + res.update({ + 'combination': [each for each in product.product_template_attribute_value_ids], + }) + return res