Skip to content

[UI] Show linked barcode string on stock detail page (#11745) - #12354

Open
mahekp05 wants to merge 164 commits into
inventree:masterfrom
mahekp05:fix-11745-linked-barcode-ui
Open

[UI] Show linked barcode string on stock detail page (#11745)#12354
mahekp05 wants to merge 164 commits into
inventree:masterfrom
mahekp05:fix-11745-linked-barcode-ui

Conversation

@mahekp05

Copy link
Copy Markdown

Description

Restores the linked (third-party) barcode string on the stock item detail page, which was visible pre-1.0 but lost after the UI rewrite.

Fixes #11745

Changes

  • Expose barcode_data as a read-only field on StockItemSerializer
  • Display a "Linked Barcode" field (copyable) on the stock detail page, shown only when a barcode is linked

Tests

  • Backend API test asserting barcode_data is exposed and read-only
  • Playwright test covering the link → display → unlink flow

mahekp05 and others added 4 commits June 21, 2026 16:11
…barcode-ui

# Conflicts:
#	src/frontend/src/pages/stock/StockDetail.tsx
Add a backend API test asserting the read-only barcode_data field is
exposed by StockItemSerializer, and a Playwright test covering the
link -> display -> unlink flow on the stock detail page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 23:19
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 0e1ca83
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a72353a3a46230008621e2e
😎 Deploy Preview https://deploy-preview-12354--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97 (no change from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Restores visibility of the linked (third-party) barcode string on the Stock Item detail page by exposing barcode_data via the StockItem API and rendering it (copyable) in the frontend, with regression coverage across backend and Playwright E2E tests.

Changes:

  • Exposes barcode_data on StockItemSerializer as a read-only field and bumps the API version.
  • Displays a conditional “Linked Barcode” (copyable) field on the stock item detail page when barcode_data is present.
  • Adds backend and Playwright regression tests for the link → display → unlink flow.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/frontend/tests/pages/pui_stock.spec.ts Adds Playwright regression test verifying linked barcode visibility toggles with link/unlink actions.
src/frontend/src/pages/stock/StockDetail.tsx Renders “Linked Barcode” detail field (copyable) when stockitem.barcode_data is present.
src/backend/InvenTree/stock/test_api.py Adds API regression test ensuring barcode_data is exposed and remains read-only via PATCH.
src/backend/InvenTree/stock/serializers.py Adds barcode_data to serializer output and marks it read-only.
src/backend/InvenTree/InvenTree/api_version.py Increments API version and documents the change in the API version text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +10
v520 -> 2026-07-10 : https://github.com/inventree/InvenTree/pull/TODO
- Adds read-only "barcode_data" field to the StockItem API endpoint
Comment on lines +344 to +351
// Link a custom barcode via the barcode actions dropdown
await page.getByLabel('action-menu-barcode-actions').click();
await page.getByLabel('action-menu-barcode-actions-link-barcode').click();

// Enter the barcode data via the keyboard input and submit
await page.getByLabel('barcode-input-scanner').click();
await page.getByLabel('barcode-scan-keyboard-input').fill('TEST-123');
await page.getByRole('button', { name: 'Link', exact: true }).click();
@SchrodingersGat

Copy link
Copy Markdown
Member

Hi @mahekp05 thanks for the PR!

If we are going to fix this we should do it in the general case - not just for the StockItem detail.

There are many other pages which support custom barcode data, so these changes should be applied to those too, and also in a generic way

@mahekp05

Copy link
Copy Markdown
Author

Hi @mahekp05 thanks for the PR!

If we are going to fix this we should do it in the general case - not just for the StockItem detail.

There are many other pages which support custom barcode data, so these changes should be applied to those too, and also in a generic way

Thanks for the feedback! I've reworked this to apply generically across all models that support custom barcodes (InvenTreeBarcodeMixin), rather than special-casing StockItem.

Approach

Backend — one shared serializer mixin
Added BarcodeSerializerMixin in InvenTree/serializers.py, which declares the read-only barcode_data field once. Each barcode-supporting serializer mixes it in and adds 'barcode_data' to its Meta.fields. For the order types this is done once on the shared AbstractOrderSerializer / order_fields(), so PurchaseOrder, SalesOrder, ReturnOrder and
TransferOrder are all covered without duplication.

Frontend — one shared helper
Added barcodeDataField(instance) in components/details/Details.tsx, which returns the copyable "Linked Barcode" detail field (only shown when a barcode is linked). Each detail page spreads it into its details grid (consistently in the top-left panel). The original inline StockItem block was refactored to use this helper too, so nothing is special-cased.

Coverage

The linked barcode string now displays on: Part, StockItem, StockLocation, Build, SupplierPart, ManufacturerPart, PurchaseOrder, SalesOrder, ReturnOrder, TransferOrder, SalesOrderShipment.

Files changed

Backend

  • InvenTree/serializers.py — new BarcodeSerializerMixin
  • stock/serializers.py, part/serializers.py, build/serializers.py,
    company/serializers.py, order/serializers.py — mixin wired in + barcode_data field
  • InvenTree/api_version.py — API v520 changelog
  • InvenTree/test_serializers.py — new test asserting barcode_data is exposed & read-only
    across all barcode serializers

Frontend

  • components/details/Details.tsx — new barcodeDataField helper
  • 10 detail pages wired to use it (Stock, Part, Location, Build, Manufacturer/Supplier part,
    Purchase/Sales/Return/Transfer order)

Tests

  • Generic backend test (BarcodeSerializerMixinTest) covering all 11 serializers
  • Existing StockItem end-to-end API test retained
  • Playwright test covering the link → display → unlink flow

Open to feedback — happy to adjust the placement, naming, or approach if you'd prefer it done differently, or if any other changes are needed.

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM in general

Comment thread src/backend/InvenTree/InvenTree/serializers.py
*
* The field is copyable and only rendered when a barcode is linked to the instance.
*/
export function barcodeDataField(instance: any): DetailsField {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SchrodingersGat do we need to do a memo trick here?

@matmair

matmair commented Jul 27, 2026

Copy link
Copy Markdown
Member

@SchrodingersGat imo the approach looks good; I think this would be - in general - be ready for a merge

@mahekp05 a few merge conflicts have creeped in; please adress these

SchrodingersGat and others added 13 commits August 3, 2026 23:02
* Support initial filters for UseCalendar

* [UI] Calendar updates

- Allow calendars to display completed / cancelled items also
)

Bumps the dependencies group with 3 updates: [actions/cache](https://github.com/actions/cache), [oasdiff/oasdiff-action](https://github.com/oasdiff/oasdiff-action) and [CodSpeedHQ/action](https://github.com/codspeedhq/action).


Updates `actions/cache` from 4.3.0 to 5.0.5
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@0057852...27d5ce7)

Updates `oasdiff/oasdiff-action` from 0.0.48 to 0.0.51
- [Release notes](https://github.com/oasdiff/oasdiff-action/releases)
- [Commits](oasdiff/oasdiff-action@50e6a34...f30668f)

Updates `CodSpeedHQ/action` from 4.15.1 to 4.17.0
- [Release notes](https://github.com/codspeedhq/action/releases)
- [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md)
- [Commits](CodSpeedHQ/action@3194d9a...9d332c4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: 5.0.5
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: dependencies
- dependency-name: oasdiff/oasdiff-action
  dependency-version: 0.0.51
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
- dependency-name: CodSpeedHQ/action
  dependency-version: 4.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…dal (inventree#12128)

* add new hotkey registration interface and hotkey modal

* fix import

* add printing hotkey

* add todo

* add hotkey for barcode scanning

* register spotlight shortcut key

* sort keys

* render nicer overview

* fix props

* expose for plugins

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
* bump container deps

* specific n version

* switch to nvm as n is not officially supported

* fix bash script

* fix corepack

* move yarn config inline

* revert nvm usage
Add spotlight action to quickly jump to user management panel
- Display last update date
- Display updating user
- Improved formatting
* Enforce min width for drop-down filters

* Pass active filter to owner  column

* Fix filter name

* Add active filter to UserFilter by default
* Check model permissions for printing

* Add unit tests

* Prevent printing of disabled reports

* Updated unit test

* Adjust unit test for printing

* Update API and CHANGELOG
…ntree#12151)

* Make plugin registry hash independent of plugin discovery order

calculate_plugin_hash() iterates self.plugins.items() in insertion
order, which is the plugin discovery order of the local process. Two
processes can hold the same registry state (same plugins, versions,
active flags) in a different order and compute different hashes,
ping-ponging the _PLUGIN_REGISTRY_HASH setting and triggering endless
registry reloads in check_reload().

Sort by slug before hashing so the hash represents the registry state
rather than the iteration order of any particular process. Add a
regression test that reverses the plugin dict and asserts the hash is
unchanged.

* Address review comments: explicit sort key, guard against vacuous test

---------

Co-authored-by: Nasawa <christopher@anigeek.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Enable in-column filtering for model type

* Enable sorting by label size

* Enable backend ordering

* Improve filtering for report template table

* Update API version
SchrodingersGat and others added 27 commits August 3, 2026 23:13
* [bug] Check for null line_item when receiving items

* Additional unit testing

* Additional context

* Fix tests
* Robustify playwright tests

* More test tweaks
* Fix currency choices for PartPricing model

- Remove dynamic choices from model definition
- Move validation step to the serializer
- Add validator to ensure only valid currencies can be used

* Add regression test

* Bump API version
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
* Update plugin name

* Backup accessor for plugin name

* Add null check for plg_db
* Adjust default behavior of "migrate" command

- Does not create new migration files automatically

* Add dummy field - ensure detected by CI

* Revert "Add dummy field - ensure detected by CI"

This reverts commit e7a101f.

* Fix typo

* Adjust contributing docs

* Add CHANGELOG entry
* Enable download from frontend panels

* Enable data import for part internal pricing

* Bump API version

* Update CHANGELOG
* Simplify navigation links

* simplify version.py

* Simplify docs links

* Consolidate
* Enhanced documentation for admin center and django-admin

* Fix links and wording

* remove placeholders

* Fix links

* Fix more links
- Ensure currency options are loaded dynamically
* Refactor API form fields

- Prevent reconstruction of all fields when single value changes
- Memoize components more intelligently
- Fix enter key callback ref

* memoize other field types too

* More memo

* Prevent duplicate API calls for related model field

* Add aria-label for IconField

* add playwright tests for form field coverage
* Parallel initial requests

* Remove debouncing

* Refactor lazy loading of desktop / mobile view

* Reduce initial waiting for loadable components

* Fix duplication of API calls

* Further reduce duplicate calls

* Combine user roles into /user/me/ endpoint

* lazy load global import drawer

* lazy load table in plugin context

* Patch ScanButton

* Added playwright tests for login

* Adjust thresholds
* Bug fixes for PO receive

- Fix shadowed variable
- Notify listeners for all received items

* Cache part subs
- More useful error messaging if a task fails
Add a backend API test asserting the read-only barcode_data field is
exposed by StockItemSerializer, and a Playwright test covering the
link -> display -> unlink flow on the stock detail page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Fixes bug where imported data headers get out of sync
- Additional unit tests
* Refactor StockItem methods

- Refactor out common functionality
- Code cleanup

* Cleanup

* Prevent override of existing deltas
…barcode-ui

# Conflicts:
#	src/backend/InvenTree/InvenTree/api_version.py
#	src/backend/InvenTree/InvenTree/test_serializers.py
#	src/backend/InvenTree/build/serializers.py
#	src/backend/InvenTree/stock/test_api.py
#	src/frontend/src/pages/build/BuildDetail.tsx
#	src/frontend/src/pages/company/ManufacturerPartDetail.tsx
#	src/frontend/src/pages/company/SupplierPartDetail.tsx
#	src/frontend/src/pages/part/PartDetail.tsx
#	src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx
#	src/frontend/src/pages/sales/ReturnOrderDetail.tsx
#	src/frontend/src/pages/sales/SalesOrderDetail.tsx
#	src/frontend/src/pages/stock/LocationDetail.tsx
#	src/frontend/src/pages/stock/StockDetail.tsx
#	src/frontend/src/pages/stock/TransferOrderDetail.tsx
@mahekp05

mahekp05 commented Aug 4, 2026

Copy link
Copy Markdown
Author

@matmair @SchrodingersGat I just updated the branch with the latest master and resolved all conflicts.

master had refactored the detail pages into DetailsPanel components, so I moved barcodeDataField(instance) into each new panel and kept the shared helper + backend BarcodeSerializerMixin. Bumped API to v531.

Branch is now conflict-free.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.74%. Comparing base (5be99b2) to head (0e1ca83).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12354   +/-   ##
=======================================
  Coverage   86.73%   86.74%           
=======================================
  Files        1445     1445           
  Lines       96340    96395   +55     
  Branches    11229    11229           
=======================================
+ Hits        83561    83615   +54     
- Misses      12715    12716    +1     
  Partials       64       64           
Flag Coverage Δ
backend 90.75% <98.21%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.15% <100.00%> (+<0.01%) ⬆️
Backend General 93.53% <ø> (ø)
Frontend 79.66% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Show linked barcode string in user interface