Skip to content

feat: add piece_count and piece_size fields to BomItem for cut-to-length parts#12422

Open
amanjain57-gif wants to merge 1 commit into
inventree:masterfrom
amanjain57-gif:feature/bom-cut-to-length-parts
Open

feat: add piece_count and piece_size fields to BomItem for cut-to-length parts#12422
amanjain57-gif wants to merge 1 commit into
inventree:masterfrom
amanjain57-gif:feature/bom-cut-to-length-parts

Conversation

@amanjain57-gif

Copy link
Copy Markdown

Summary

Addresses #10274

Manufacturing BOMs frequently require multiple pieces of a specific size cut from continuous stock (cables, tubing,
structural profiles). Currently the only way to express "10 pieces of 250mm cable" is to enter the total length (2.5m)
as quantity, which loses the piece-count information that purchasing and production need.

Changes

Adds two optional fields to BomItem:

  • piece_count: number of discrete pieces required (default: 1)
  • piece_size: size/length of each piece (e.g. "250 mm")

When piece_size is specified, the total quantity is auto-calculated as piece_count × piece_size, maintaining full
backward compatibility (existing items effectively have piece_count=1 and empty piece_size).

Backend

  • New model fields with migration
  • Updated recalculate_quantity() to compute total from piece_count × piece_size when piece_size is set
  • Added fields to BOM item hash for validation checksum

API

  • Serializer exposes piece_count and piece_size fields

Frontend

  • BOM creation/edit form includes the new fields
  • BOM table shows piece_count and piece_size as optional (hidden by default) columns

Example

A BOM line for "10 pieces of 250mm aluminum profile" (part units: m):

  • piece_count: 10
  • piece_size: "250 mm"
  • Auto-calculated quantity: 2.5 (meters)

This preserves the per-piece information for production while correctly computing total material requirement for
purchasing.

…gth parts

Manufacturing BOMs frequently require multiple pieces of a specific size
cut from continuous stock (cables, tubing, structural profiles). Currently
the only way to express "10 pieces of 250mm cable" is to enter the total
length (2.5m) as quantity, which loses the piece-count information that
purchasing and production need.

This adds two optional fields to BomItem:
- piece_count: number of discrete pieces required (default: 1)
- piece_size: size/length of each piece (e.g. "250 mm")

When piece_size is specified, the total quantity is auto-calculated as
piece_count × piece_size, maintaining full backward compatibility (existing
items effectively have piece_count=1 and empty piece_size).

Changes:
- Backend: new model fields, migration, updated recalculate_quantity()
  logic, hash_fields for BOM validation
- API: serializer exposes piece_count and piece_size
- Frontend: BOM form includes the new fields, BOM table shows them as
  optional columns

Addresses inventree#10274
@netlify

netlify Bot commented Jul 19, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 06d35d9
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a5c194a523bd50008692dd3
😎 Deploy Preview https://deploy-preview-12422--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.

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.

1 participant