Skip to content
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

[15.0] [IMP] barcodes, point_of_sale: Scanning Barcodes (Multiple Rules Apply) #574

Open
wants to merge 3 commits into
base: 15.0
Choose a base branch
from

Conversation

hugho-ad
Copy link
Collaborator

@hugho-ad hugho-ad commented Dec 8, 2023

OPW #2841018

[FIX] barcodes: Parsing Barcodes (Multiple Rules Apply)

Now when the Barcode match with multiple barcode patterns in the rules of the Barcode Nomenclatures all the possible matching will be returned instead of only returning the first option.

This will solve the issue that exists when more than one rule has the same barcode pattern [1] and allow doing those searches and not only searching for one option when the result can be in the second option.

For example, before this change having the "Customer Barcodes" and "Product Barcodes" with the same pattern .* as rules in the Barcode Nomenclatures if we scan in the POS the barcode "0020200002" the first that applies will be the customer for the sequence in the POS if we search for a product with the barcode "0020200002" the first rule will be "Customer" for the sequence and if there is no customer with that barcode it will return an error saying "The Point of Sale could not find any product, client, employee or action associated with the scanned barcode." which is not true because there is a product with that barcode.

Now it will return both rules instead of only the first one, also we add in the results the rule that is matching in order to keep the return almost the same as in the module barcodes_gs1_nomenclature in the method parse_gs1_rule_pattern (that is inside of their parser) returns the rule and the stock_barcode module in Odoo Enterprise use it.

[1] odoo#90353

[FIX] point_of_sale: Barcode Error

As we can now have multiple rules (Barcode Nomenclatures) that apply in the parse of the barcode we have multiple parsed results that we can search in the scanning process we had to avoid showing the error of the function _barcodeErrorAction when we have more parsed results to search into so now we only want to show it when is the last result and none of the callbacks returned a successful response.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@hugho-ad
Copy link
Collaborator Author

hugho-ad commented Dec 8, 2023

@CarmenMiranda could you please review

cc @JVegaB

@CarmenMiranda
Copy link

Technically LGTM 👍🏼

It maintains both the idea of the new change that Odoo made and the idea of the previous PR (#499)

@hugho-ad hugho-ad added the PATCH label Dec 8, 2023
Now when the Barcode match with multiple barcode patterns in the rules
of the Barcode Nomenclatures all the possible matching will be returned
instead of only returning the first option.

This will solve the issue that exists when more than one rule has the
same barcode pattern [1] and allow doing those searches and not only
searching for one option when the result can be in the second option.

For example, before this change having the "Customer Barcodes" and
"Product Barcodes" with the same pattern `.*` as rules in the Barcode
Nomenclatures if we scan in the POS the barcode "0020200002" the first
that applies will be the customer for the sequence
in the POS if we search for a product with the
barcode "0020200002" the first rule will be "Customer" for the sequence
and if there is no customer with that barcode it will return an error
saying "The Point of Sale could not find any product, client, employee
or action associated with the scanned barcode." which is not true
because there is a product with that barcode.

Now it will return both rules instead of only the first one, also we add
in the results the rule that is matching in order to keep the return
almost the same as in the module `barcodes_gs1_nomenclature` in the
method `parse_gs1_rule_pattern` (that is inside of their parser) returns
the rule and the `stock_barcode` module in Odoo Enterprise use it.

[1] [Issue 90353: Unknown Barcode in POS when Product exists](odoo#90353)
@hugho-ad hugho-ad force-pushed the 15.0-Multi-Barcode-Rules-POS branch from 24f815b to 4c961ca Compare June 12, 2024 01:25
As we can now have multiple rules (Barcode Nomenclatures) that apply in
the parse of the barcode we have multiple parsed results that we can
search in the scanning process we had to avoid showing the error of the
function `_barcodeErrorAction` when we have more parsed results to
search into so now we only want to show it when is the last result
and none of the callbacks returned a successful response.
@hugho-ad hugho-ad force-pushed the 15.0-Multi-Barcode-Rules-POS branch from 4c961ca to 2eb74a2 Compare June 12, 2024 04:59
…Barcodes (Multiple Rules Apply)

Fix this since gs1 nomenclatures could return more than one result
 https://github.com/odoo-dev/odoo/blob/a764f029514a45a77f4fb977ee1306a510aeefa2/addons/barcodes_gs1_nomenclature/static/src/js/barcode_parser.js#L105
This conflicts with the actual patch that try to find all the rules applying to the barcode
in order to ensure the proper fiding of it.

Now we filter out parsed results by the type of the nomenclature they belong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants