-
-
Notifications
You must be signed in to change notification settings - Fork 210
[16.0][MIG] shopfloor_gs1 #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rousseldenis
wants to merge
13
commits into
OCA:16.0
Choose a base branch
from
acsone:16.0-add_gs1-dro
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f287cd4
Add shopfloor_gs1
simahawk 6ca51dd
shopfloor_gs1: pin biip==2.3.0
simahawk 9d667d5
shopfloor_gs1: refactor mapping handling
simahawk 0abaf5b
shopfloor_gs1: add tests for scan_anything
simahawk 4bf0a20
shopfloor_gs1: skip search if no AI found
simahawk 3c9b18c
fixup! shopfloor_gs1: pin biip==2.3.0
sebalix 93b38af
[IMP] shopfloor_gs1: pre-commit stuff
rousseldenis 969a54a
[MIG][16.0] shopfloor_gs1
rousseldenis a612edd
[IMP] shopfloor_gs1: Add a parser for GS1 / Add expiration date manag…
rousseldenis bf6d4c5
[DONT MERGE] test-requirements.txt
rousseldenis ef8343c
[IMP] shopfloor_gs1: Return correct value for parsing / typing
rousseldenis 8a5f841
[FIX] shopfloor_gs1: Don't mix GTIN-13 and GTIN-14
rousseldenis 6da2cd6
[IMP] shopfloor_gs1: Also return the other parsing results
rousseldenis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # generated from manifests external_dependencies | ||
| biip | ||
| openupgradelib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../shopfloor_gs1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import setuptools | ||
|
|
||
| setuptools.setup( | ||
| setup_requires=['setuptools-odoo'], | ||
| odoo_addon=True, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| ============= | ||
| Shopfloor GS1 | ||
| ============= | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:15ac24e92ed1dc3217969411ccf2ffaba7bd0a61c8eabadcab6cdb06030189cd | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/wms/tree/16.0/shopfloor_gs1 | ||
| :alt: OCA/wms | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_gs1 | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/wms&target_branch=16.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| Add GS1 barcode support to Shopfloor. | ||
|
|
||
| Based on https://biip.readthedocs.io/ | ||
|
|
||
| This module allows to use the biip library to interpret a scanned GS1 barcode | ||
| and return the corresponding Odoo record for Shopfloor `find` method. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| - You can use the `Scan` action in Shopfloor with a GS1 barcode. The | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_gs1%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ~~~~~~~ | ||
|
|
||
| * Camptocamp | ||
|
|
||
| Contributors | ||
| ~~~~~~~~~~~~ | ||
|
|
||
| * Simone Orsi <simone.orsi@camptocamp.com> | ||
| * Sébastien Alix <sebastien.alix@camptocamp.com> | ||
| * Denis Roussel <denis.roussel@acsone.eu> | ||
|
|
||
| Maintainers | ||
| ~~~~~~~~~~~ | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| .. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px | ||
| :target: https://github.com/simahawk | ||
| :alt: simahawk | ||
| .. |maintainer-sebalix| image:: https://github.com/sebalix.png?size=40px | ||
| :target: https://github.com/sebalix | ||
| :alt: sebalix | ||
|
|
||
| Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-simahawk| |maintainer-sebalix| | ||
|
|
||
| This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/16.0/shopfloor_gs1>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright 2022 Camptocamp SA (http://www.camptocamp.com) | ||
| # @author Simone Orsi <simahawk@gmail.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| { | ||
| "name": "Shopfloor GS1", | ||
| "summary": "Integrate GS1 barcode scan into Shopfloor app", | ||
| "version": "16.0.1.0.0", | ||
| "development_status": "Beta", | ||
| "category": "Inventory", | ||
| "website": "https://github.com/OCA/wms", | ||
| "author": "Camptocamp, Odoo Community Association (OCA)", | ||
| "maintainers": ["simahawk", "sebalix"], | ||
| "license": "AGPL-3", | ||
| "depends": ["shopfloor"], | ||
| "external_dependencies": { | ||
| "python": [ | ||
| # >= 2.3.0 required to use 'GS1Message.parse_hri' method | ||
| # and next version 3.0.0 has been refactored bringing | ||
| # incompatibility issues (to check later). | ||
| "biip" | ||
| ] | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import search |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Copyright 2022 Camptocamp SA (http://www.camptocamp.com) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo.addons.component.core import Component | ||
| from odoo.addons.shopfloor.actions.barcode_parser import BarcodeResult | ||
|
|
||
| from ..config import MAPPING_AI_TO_TYPE, MAPPING_TYPE_TO_AI | ||
| from ..utils import GS1Barcode | ||
|
|
||
|
|
||
| class BarcodeParser(Component): | ||
| """ | ||
| Some barcodes can have complex data structure | ||
| """ | ||
|
|
||
| _inherit = "shopfloor.barcode.parser" | ||
|
|
||
| def _search_type_to_gs1_ai(self, _type): | ||
| """Convert search type to AIs. | ||
|
|
||
| Each type can be mapped to multiple AIs. | ||
| For instance, you can search a product by barcode (01) or manufacturer code (240). | ||
| """ | ||
| return MAPPING_TYPE_TO_AI.get(_type) | ||
|
|
||
| def _gs1_ai_to_search_type(self, ai): | ||
| """Convert back GS1 AI to search type.""" | ||
| return MAPPING_AI_TO_TYPE[ai] | ||
|
|
||
| def _parse_gs1(self, barcode, types, safe=True) -> list[GS1Barcode]: | ||
| types = types or () | ||
| ai_whitelist = () | ||
| # Collect all AIs by converting from search types | ||
| for _type in types: | ||
| ai = self._search_type_to_gs1_ai(_type) | ||
| if ai: | ||
| ai_whitelist += ai | ||
| if types and not ai_whitelist: | ||
| # A specific type was asked but no AI could be found. | ||
| return list() | ||
| parsed = GS1Barcode.parse(barcode, ai_whitelist=ai_whitelist, safe=safe) | ||
| return parsed | ||
|
|
||
| def parse(self, barcode, types): | ||
| """ | ||
| This method will parse the barcode and return the | ||
| value with its type if determined. | ||
|
|
||
| Override this to implement specific parsing | ||
|
|
||
| """ | ||
| # Retrieve in any case the 'unknown' parsing with raw barcode | ||
| result = super().parse(barcode, types) | ||
| parsed = self._parse_gs1(barcode, types) | ||
| if parsed: | ||
| for barcode_type in self.search_action._barcode_type_handler.keys(): | ||
| for parsed_item in parsed: | ||
| if parsed_item.ai in MAPPING_TYPE_TO_AI.get(barcode_type, tuple()): | ||
| result.append( | ||
| BarcodeResult( | ||
| type=barcode_type, | ||
| value=parsed_item.value, | ||
| raw=parsed_item.raw_value, | ||
| ) | ||
| ) | ||
| return result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright 2022 Camptocamp SA (http://www.camptocamp.com) | ||
| # @author Simone Orsi <simahawk@gmail.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| # https://www.gs1.org/standards/barcodes/application-identifiers | ||
| # TODO: define other internal mappings by convention | ||
|
|
||
|
|
||
| # Each type can be mapped to multiple AIs. | ||
| # For instance, you can search a product by barcode (01) or manufacturer code (240). | ||
| MAPPING_TYPE_TO_AI = { | ||
| "product": ("01", "240"), | ||
| "lot": ("10",), | ||
| "production_date": ("11",), | ||
| "expiration_date": ("17",), | ||
| "serial": ("21",), | ||
| "manuf_product_code": ("240",), | ||
| "location": ("254",), | ||
| } | ||
| MAPPING_AI_TO_TYPE = { | ||
| "01": "product", | ||
| "10": "lot", | ||
| "11": "production_date", | ||
| "17": "expiration_date", | ||
| "21": "serial", | ||
| "240": "product", | ||
| "254": "location", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| * Simone Orsi <simone.orsi@camptocamp.com> | ||
| * Sébastien Alix <sebastien.alix@camptocamp.com> | ||
| * Denis Roussel <denis.roussel@acsone.eu> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Add GS1 barcode support to Shopfloor. | ||
|
|
||
| Based on https://biip.readthedocs.io/ | ||
|
|
||
| This module allows to use the biip library to interpret a scanned GS1 barcode | ||
| and return the corresponding Odoo record for Shopfloor `find` method. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - You can use the `Scan` action in Shopfloor with a GS1 barcode. The |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pin of the lib is lost here. It's mandatory as there's no other 2.x version that is suitable