Skip to content

[18.0][ADD] barcode_stock_product_multi_barcode - #22

Open
antoniodavid wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-barcode_stock_product_multi_barcode
Open

antoniodavid wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-barcode_stock_product_multi_barcode

Conversation

@antoniodavid

@antoniodavid antoniodavid commented Nov 6, 2026 •

Copy link
Copy Markdown

Bridge between product_multi_barcode (OCA/stock-logistics-barcode) and barcode_stock: in the Barcode app, scanning any of a product's alternate barcodes resolves to the same move as its main barcode.

Why it is needed

product_multi_barcode lets a product hold several barcodes (its main one plus alternates), but barcode_stock only indexes the main barcode and the packagings when it preloads a picking. Scanning an alternate barcode is then rejected even though the product is on the move in that picking.

What it does

  • On preload of a picking, reads the product.barcode records of the products it contains and adds every alternate barcode to the scanner's barcodeToProductIds index, so a scan of any of them yields the same move candidates as the main barcode.
  • Clears the alternates on reset, so a new picking starts clean.
  • If the user cannot read product.barcode, the picking still loads and the scanner falls back to main barcodes and packagings.
  • Installs itself when both barcode_stock and product_multi_barcode are installed (auto_install), and changes neither module.

How to use

  1. Install barcode_stock and product_multi_barcode; this module installs itself.
  2. On a product, add the alternate barcodes in the Barcodes list next to the main barcode.
  3. Open a picking with that product in the Barcode app and scan an alternate barcode: it resolves to the same move as the main one.

@BinhexTeam T26645

@OCA-git-bot OCA-git-bot added series:18.0 mod:barcode_stock_product_multi_barcode Module barcode_stock_product_multi_barcode labels Nov 6, 2026
@antoniodavid

Copy link
Copy Markdown
Author

ping @edescalona @szalatyzuzanna

@szalatyzuzanna

Copy link
Copy Markdown

Thanks for the PR! Before reviewing it, could you add a description? A short summary of what the addon does and why it's needed, plus how to use or test it

@antoniodavid

Copy link
Copy Markdown
Author

Thanks @szalatyzuzanna — I've added a description to the PR body: what the module does and why it is needed, how to use it, and what the tests cover (plus the Runboat link).

@edescalona edescalona left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Code review OK.

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read against barcode_stock's preload and index build; the HOOT suite is green in CI and I did not repeat it locally. The ordering point is read from the code.

@antoniodavid
antoniodavid force-pushed the 18.0-add-barcode_stock_product_multi_barcode branch from 845edc3 to 8ff46d8 Compare November 17, 2026 17:11

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installed the module at 8ff46d8 and ran preloadPicking on a real picking in a throwaway 18.0 database: the ordering fix holds. The HOOT suite was green in CI; I did not rerun it here. One more concern below.

Comment on lines +69 to +72
indexes.barcodeToProductIds[code] = [
...(indexes.barcodeToProductIds[code] || []),
productId,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product_multi_barcode keeps a product's main barcode as a product.barcode row too (_compute_barcode = barcode_ids[:1].name), so this read returns it as well. Ran on 18.0 with one move and one alternate: the index ends with the same product twice for the main barcode, and getMoveCandidatesForBarcode() returns that move twice. The picking screen only reads candidates[0] and this fixture returns the alternates alone, so nothing is visibly wrong today.

Suggested change
indexes.barcodeToProductIds[code] = [
...(indexes.barcodeToProductIds[code] || []),
productId,
];
const known = indexes.barcodeToProductIds[code] || [];
if (!known.includes(productId)) {
indexes.barcodeToProductIds[code] = [...known, productId];
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! Nothing reads past candidates[0] today, but I'd rather keep the index free of duplicates before merging. @antoniodavid, could you apply this suggestion and add a test asserting the main barcode maps to the product only once?

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Comment on lines +69 to +72
indexes.barcodeToProductIds[code] = [
...(indexes.barcodeToProductIds[code] || []),
productId,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! Nothing reads past candidates[0] today, but I'd rather keep the index free of duplicates before merging. @antoniodavid, could you apply this suggestion and add a test asserting the main barcode maps to the product only once?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:barcode_stock_product_multi_barcode Module barcode_stock_product_multi_barcode series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants