Skip to content

Commit

Permalink
[MIG] website_sale_barcode_search: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiosca-s73 authored and ferran-S73 committed Oct 3, 2024
1 parent 598de62 commit 7b73f4f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion website_sale_barcode_search/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import controllers
from . import models
2 changes: 1 addition & 1 deletion website_sale_barcode_search/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Website Sale Barcode Search",
"category": "E-Commerce",
"summary": "It improve website product search adding search by barcode",
"version": "14.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["website_sale"],
"author": "Studio73, Odoo Community Association (OCA)",
Expand Down
1 change: 0 additions & 1 deletion website_sale_barcode_search/controllers/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions website_sale_barcode_search/controllers/website_sale.py

This file was deleted.

2 changes: 2 additions & 0 deletions website_sale_barcode_search/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_template
from . import website
16 changes: 16 additions & 0 deletions website_sale_barcode_search/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Studio73 - Miguel Gandia
# Copyright 2024 Studio73 - Sergi Biosca
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo import api, models


class ProductTemplate(models.Model):
_inherit = "product.template"

@api.model
def _search_get_detail(self, website, order, options):
res = super()._search_get_detail(website, order, options)
res["search_fields"].append("barcode")
return res
19 changes: 19 additions & 0 deletions website_sale_barcode_search/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Studio73 - Ferran Mora
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models


class Website(models.Model):
_inherit = "website"

def _trigram_enumerate_words(self, search_details, search, limit):
final_search_details = []

Check warning on line 11 in website_sale_barcode_search/models/website.py

View check run for this annotation

Codecov / codecov/patch

website_sale_barcode_search/models/website.py#L11

Added line #L11 was not covered by tests
for detail in search_details:
if detail.get("model", "") == "product.template":
search_fields = detail.get("search_fields", [])

Check warning on line 14 in website_sale_barcode_search/models/website.py

View check run for this annotation

Codecov / codecov/patch

website_sale_barcode_search/models/website.py#L14

Added line #L14 was not covered by tests
if search_fields:
search_fields.remove("barcode")
detail["search_fields"] = search_fields
final_search_details.append(detail)
return super()._trigram_enumerate_words(final_search_details, search, limit)

Check warning on line 19 in website_sale_barcode_search/models/website.py

View check run for this annotation

Codecov / codecov/patch

website_sale_barcode_search/models/website.py#L16-L19

Added lines #L16 - L19 were not covered by tests

0 comments on commit 7b73f4f

Please sign in to comment.