[18.0][FIX] pos_lot_barcode: Collapse product array when length > 0 #1430
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.
When scanning a lot/serial barcode that resolves to exactly one
stock.lot,_getProductByLotBarcodefetches the relatedproduct.productvia:searchReadalways returns an array. The current code only collapses the result whenlength > 1, so whenlength === 1the variableproductremains an Array and is returned as such.Upstream,
_barcodeLotActionchecks:This branch assumes an array of lots (with
product_id), but it actually receives an array of products. That mismatch raises an exception while accessinglot.product_idand then.nameon an undefined lookup.Current behavior before PR
_barcodeLotActiontreats it as multiple lots and executes the mapping above.productNamesStringinstead of adding the product line because a product object does not have a product_id attribute, therefore this.pos.models["product.product"].get fails to look up the productDesired behavior after PR is merged
searchRead("product.product", ...)are collapsed to a record (product = product[0])._barcodeLotActionreceives a product record (not an array) and proceeds to add the product to the order.length === 0),_getProductByLotBarcodecorrectly returnsfalse(“not available in POS”).