Skip to content

Commit

Permalink
[FIX] oxigen_stock_barcodes_gs1: manage product multi barcode when ar…
Browse files Browse the repository at this point in the history
…e scanned
  • Loading branch information
FrankC013 committed Mar 13, 2024
1 parent a9188e5 commit 0cd1a56
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion oxigen_stock_barcodes_gs1/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Oxigen stock barcodes GS1
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2580c1861591aef093578d851da478d6c965f38c50cfe353ce43edee1d99385c
!! source digest: sha256:8c35974b642e8e87983299f5b009cf43515fe9701359b8eff67f3dcf3685be2a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
6 changes: 5 additions & 1 deletion oxigen_stock_barcodes_gs1/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"author": "ForgeFlow",
"website": "https://github.com/oxigensalud/odoo-addons",
"category": "Extra Tools",
"depends": ["stock_barcodes_gs1_expiry", "oxigen_stock_barcodes"],
"depends": [
"stock_barcodes_gs1_expiry",
"oxigen_stock_barcodes",
"product_multi_barcode",
],
"data": ["wizard/stock_barcodes_new_lot_views.xml"],
"installable": True,
"license": "AGPL-3",
Expand Down
2 changes: 1 addition & 1 deletion oxigen_stock_barcodes_gs1/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Oxigen stock barcodes GS1</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2580c1861591aef093578d851da478d6c965f38c50cfe353ce43edee1d99385c
!! source digest: sha256:8c35974b642e8e87983299f5b009cf43515fe9701359b8eff67f3dcf3685be2a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/oxigensalud/odoo-addons/tree/14.0/oxigen_stock_barcodes_gs1"><img alt="oxigensalud/odoo-addons" src="https://img.shields.io/badge/github-oxigensalud%2Fodoo--addons-lightgray.png?logo=github" /></a></p>
<ul class="simple">
Expand Down
22 changes: 8 additions & 14 deletions oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,15 @@ def process_barcode(self, barcode): # noqa: C901
product_barcode = barcode_decoded.get("240", False)
product_qty = barcode_decoded.get("37", False)
if product_barcode:
# Flushing the relevant fields of the involved models
self.env["product.product"].flush(["barcode"])
self.env["product.template"].flush(["company_id"])
self.env.cr.execute(
"""
SELECT pp.id
FROM product_product pp
JOIN product_template pt ON pp.product_tmpl_id = pt.id
WHERE LOWER(LPAD(pp.barcode, 14, '0')) = LOWER(%s)
AND (pt.company_id = %s OR pt.company_id IS NULL);
""",
(product_barcode, self.env.company.id),
products = self.env["product.product"].search(

Check warning on line 96 in oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py#L96

Added line #L96 was not covered by tests
[
("barcode", "=ilike", "%" + product_barcode.lstrip("0")),
("company_id", "in", (self.env.company.id, False)),
]
)
products = self.env.cr.fetchall()
product = self.env["product.product"].browse([x[0] for x in products])
product = products.barcode_ids.filtered(
lambda x: x.name.zfill(14) == product_barcode
).product_id
if len(product) > 1:
self._set_messagge_info(

Check warning on line 106 in oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

oxigen_stock_barcodes_gs1/wizard/stock_barcodes_read.py#L106

Added line #L106 was not covered by tests
"not_found",
Expand Down

0 comments on commit 0cd1a56

Please sign in to comment.