Skip to content

[ADD] barcode_gs1_stock: the GS1 measure as the quantity, in the product's unit - #9

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-barcode_gs1_stock
Oct 28, 2026
Merged

OCA-git-bot merged 1 commit into
OCA:18.0from
BinhexTeam:18.0-add-barcode_gs1_stock

Conversation

@szalatyzuzanna

@szalatyzuzanna szalatyzuzanna commented Oct 9, 2026 •

Copy link
Copy Markdown

Bridge between barcode_gs1 and barcode_stock: the measure on a GS1 label becomes the quantity picked, in the unit the product is stocked in.

Depends on #8. That PR's commit is included here so CI can install barcode_gs1; this branch will be rebased once it is merged, leaving only the barcode_gs1_stock commit.

Why a separate module

A GS1 label often states both a piece count (AI 30/37) and a measure (AI 310n and the like): a box of cured meat carries "2 pieces" and "2.497 kg". Which one is the quantity depends on how the product is stocked, which neither module can decide on its own:

  • barcode_gs1 only decodes the label. It doesn't know the product, so the quantity it reports is the piece count (null when the label states none), and the measure stays in weight/weightUom.
  • barcode_stock doesn't know GS1. It takes the scanned quantity as it comes.

It installs itself when both modules are there.

What it does

barcode_stock's scannedQuantity and applyScanResult are overridden:

  • when the unit the measure is in (the Unit of Measure on the barcode rule that read it) is in the same category as the product's unit, the measure is the quantity, converted with the units' factors: 2.497 kg is 2497 for a product in grams;
  • when it isn't (a weight for a product counted in units), the piece count is the quantity, or one unit when the label states none. A weight never becomes a number of units;
  • without a measure, or with units it can't read, the base behaviour stands;
  • on a packaging barcode, a measure in the product's kind of unit wins over the pack's quantity: a carton of cheese weighing 4.32 kg is 4.32 for a product in kilograms, not 12. Without a measure the base behaviour stands: the pack's quantity, or the count on the label.

The quantity is rounded the way the server stores it: to the product unit's Rounding Precision, then to the Product Unit of Measure decimals. With Odoo's defaults 2.497 kg is shown as 2.50, which is what gets stored. readme/CONFIGURE.md explains how to keep the grams.

The units of measure and the Product Unit of Measure decimals are read once when the app starts, because the scan path is synchronous.

Tests

  • A HOOT suite for the quantity rules, run through browser_js. It includes the rounding and carton labels read by the real barcode_gs1 parser against a packaging of 12.
  • A check that a plain internal user can make the startup calls (units of measure, decimal precision) through the RPC route.

@BinhexTeam

@OCA-git-bot OCA-git-bot added series:18.0 mod:barcode_gs1 Module barcode_gs1 mod:barcode_gs1_stock Module barcode_gs1_stock labels Oct 9, 2026
@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-add-barcode_gs1_stock branch from 40da2c4 to 05231b5 Compare October 9, 2026 10:50
@szalatyzuzanna
szalatyzuzanna marked this pull request as ready for review October 9, 2026 10:55
@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-add-barcode_gs1_stock branch from 05231b5 to b00bad4 Compare October 9, 2026 11:32
@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-add-barcode_gs1_stock branch from b00bad4 to 8069e4b Compare October 9, 2026 14:00

@oliverg09 oliverg09 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.

LGTM!

@jorgeglez1990 jorgeglez1990 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.

Functional review. LGTM

@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). 🤖

@jelenapoblet jelenapoblet 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.

LGTM

@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@jelenapoblet The merge process could not be finalized, because command twine upload --disable-progress-bar --non-interactive --repository-url https://upload.pypi.org/legacy/ -u __token__ odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl failed with output:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl
�[33mWARNING �[0m Error during upload. Retry with the --verbose option for more details. 
�[31mERROR   �[0m HTTPError: 429 Too Many Requests from https://upload.pypi.org/legacy/  
         Too Many Requests                                                      

@jelenapoblet

Copy link
Copy Markdown

@OCA/pypi-support another one. Thanks

@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@jelenapoblet your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@jelenapoblet your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-add-barcode_gs1_stock branch from 8069e4b to e69a876 Compare October 21, 2026 13:58
@OCA-git-bot OCA-git-bot removed the mod:barcode_gs1 Module barcode_gs1 label Oct 21, 2026
@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@jelenapoblet The merge process could not be finalized, because command twine upload --disable-progress-bar --non-interactive --repository-url https://upload.pypi.org/legacy/ -u __token__ odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl failed with output:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl
�[33mWARNING �[0m Error during upload. Retry with the --verbose option for more details. 
�[31mERROR   �[0m HTTPError: 429 Too Many Requests from https://upload.pypi.org/legacy/  
         Too Many Requests                                                      

szalatyzuzanna added a commit to RocketCloudSaaS/barcode that referenced this pull request Oct 22, 2026
Brings the bridge in line with OCA/barcode-interface#9:
- Of the measures a label carries, the quantity is the first one in the
  product's kind of unit (a weight for a product in kilograms, a volume for
  one in litres); the pack's gross weight and other logistic measures never
  count.
- Should the units fail to load at startup, they are loaded again in the
  background when a scan carries a measure.
- A measure that rounds to nothing in the product's unit reads as a scan
  without one.
szalatyzuzanna added a commit to RocketCloudSaaS/barcode that referenced this pull request Oct 22, 2026
…n the product's unit

Brings the bridge in line with OCA/barcode-interface#9:
- The decimals the quantity is stored with are read from the field's digits
  (fields_get) instead of decimal.precision.precision_get, which fails over
  RPC once `account` is installed, so the measure was never read there.
- Of the measures a label carries, the quantity is the first one in the
  product's kind of unit; the pack's gross weight and other logistic
  measures never count.
- Should the units fail to load at startup, they are loaded again when a
  scan carries a measure; a measure that rounds to nothing reads as a scan
  without one.
szalatyzuzanna added a commit to RocketCloudSaaS/barcode that referenced this pull request Oct 22, 2026
…n the product's unit

Brings the bridge in line with OCA/barcode-interface#9:
- The decimals the quantity is stored with are read from the field's digits
  (fields_get) instead of decimal.precision.precision_get, which fails over
  RPC once `account` is installed, so the measure was never read there.
- Of the measures a label carries, the quantity is the first one in the
  product's kind of unit; the pack's gross weight and other logistic
  measures never count.
- Should the units fail to load at startup, they are loaded again when a
  scan carries a measure; a measure that rounds to nothing reads as a scan
  without one.
@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

It looks like something changed on 18.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@jelenapoblet The merge process could not be finalized, because command twine upload --disable-progress-bar --non-interactive --repository-url https://upload.pypi.org/legacy/ -u __token__ odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl failed with output:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading odoo_addon_barcode_gs1_stock-18.0.1.0.0.2-py3-none-any.whl
�[33mWARNING �[0m Error during upload. Retry with the --verbose option for more details. 
�[31mERROR   �[0m HTTPError: 429 Too Many Requests from https://upload.pypi.org/legacy/  
         Too Many Requests                                                      

@jelenapoblet

Copy link
Copy Markdown

@OCA/pypi-support please add this name when possible. Thanks

@rousseldenis

Copy link
Copy Markdown

@jelenapoblet Name reserved

@jelenapoblet

Copy link
Copy Markdown

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-9-by-jelenapoblet-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit bf873ec into OCA:18.0 Oct 28, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 84c0972. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants