Skip to content

Build Order Updates - #4855

Merged
SchrodingersGat merged 90 commits into
inventree:masterfrom
SchrodingersGat:build-order-lines
Jun 13, 2023
Merged

SchrodingersGat merged 90 commits into
inventree:masterfrom
SchrodingersGat:build-order-lines

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented May 19, 2023 •

Copy link
Copy Markdown
Member

A long-needed overhaul of the build and build allocation system.

This PR adds a new build database model, the "BuildLine"

  • Represents an instance of a BOM item against a BuildOrder
  • Is generated once when a BuildOrder is created
  • If the BOM changes (after the build is created) the items required for the build order do not change
  • Will help with speed of API queries against build orders
  • Will allows users to "break out" subassemblies into a top-level flat build order
  • Other advantages will fall out too
  • Allows calculation of "overage"

TODO

  • Fill out description
  • Data migration for existing adding BuildLine objects to build orders
  • Add data migration for assigning existing BomItem objects
  • Add migration for removing BuildItem.build column
  • Add migration for removing BuildItem.bom_item column
  • Unit testing for data migrations
  • Refactor subtract_allocated_stock
  • Refactor scrap_build_output
  • Refactor complete_build_output
  • Refactor trim_allocated_stock
  • Annotate "available" quantity to BomLine serializer
  • Annotate "allocated" quantity to BomLine serializer
  • Perform "remaining quantity" calculation on each BuildLine instance
  • Refactor "auto allocate" functionality
  • Refactor "unallocate" functionality
  • Refactor existing build reports
  • Recalculate required quantities if the total build quantity is adjusted
  • Update BuildLine objects when a BomItem is saved
  • Refactor all references to has_untracked_bom_items
  • Refactor all references to incomplete_bom_items
  • Unit testing
  • Documentation
  • Check calculation of overage in build orders
  • Fix "required for build orders" queryset annotation (should be a lot simpler now)
  • UI updates
  • API updates
  • Data migration for demo dataset - Update dataset demo-dataset#48
  • Ensure new API annotations on BuildLine model do not take O(n) time
  • Remove build.required_quantity method
  • Refactor build.has_overallocated_parts method
  • Refactor build.required_parts_to_complete_build method
  • Refactor build.unallocateStock method
  • remove old loadBuildOutputAllocationTable javascript function

- Represents an instance of a BOM item against a BuildOrder
@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature build Build orders api Relates to the API labels May 19, 2023
@SchrodingersGat
SchrodingersGat marked this pull request as draft May 22, 2023 13:49
Add list and detail API endpoints for new BuildLine model
@SchrodingersGat SchrodingersGat added this to the 0.12.0 milestone May 29, 2023
@SchrodingersGat SchrodingersGat added breaking Indicates a major update or change which breaks compatibility refactor labels Jun 6, 2023
- A "BuildItem" will now be tracked against a BuildLine
- Not tracked directly against a build
- Not tracked directly against a BomItem
- Add schema migration
- Add data migration to update links
- bom_item and build fields are about to be removed
- Set them to "nullable" so the data doesn't get removed
- build fk
- bom_item fk
- A lot of other required changes too
- Delete the BuildLine if the BomItem is removed
- This is closer to current behaviour
- tracked_bom_items -> tracked_line_items
- untracked_bom_items -> tracked_bom_items
- remove build.can_complete
- move bom_item specific methods to the BuildLine model
- Cleanup / consolidation
- Update javascript
- Cleanup HTML templates
- Annotate 'allocated' quantity
- Filter by allocated / trackable / optional / consumable
- Makes API query *much* faster now
- remove old "required_parts_to_complete_build" method
- Cleanup part API filter code
SchrodingersGat added a commit to inventree/demo-dataset that referenced this pull request Jun 11, 2023
- Migrate data to include new BuildLine model
- Ref: inventree/InvenTree#4855
@SchrodingersGat
SchrodingersGat marked this pull request as ready for review June 12, 2023 13:19
- Don't hard-code pk values
- postgresql no likey
@SchrodingersGat SchrodingersGat changed the title [WIP] Build updates Build Order Updates Jun 13, 2023
@SchrodingersGat

Copy link
Copy Markdown
Member Author

@matmair can you give your 2 cents on this issue?

https://github.com/inventree/InvenTree/actions/runs/5250684787/jobs/9484929933?pr=4855

image

For some reason, running the unit testing is generating a new migration file in the "InvenTree" app. IIRC you recently added some migration stuff here, maybe?

@matmair

matmair commented Jun 13, 2023

Copy link
Copy Markdown
Member

The interesting part is why the migration checks go through

@SchrodingersGat

Copy link
Copy Markdown
Member Author

If I run the full CI suite locally, I get a new migration file (under InvenTree/migrations) for each run through

@matmair

matmair commented Jun 13, 2023 via email

Copy link
Copy Markdown
Member

@SchrodingersGat

Copy link
Copy Markdown
Member Author

image

@matmair for example

If I run the CI tests again, I get another migration each time, i.e. 0003, 0004, 0005

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Although the empty migration is strange, it looks like the coveralls error is on their end. An earlier run from today had the same message, but still uploaded:

image

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Looks like coveralls is just down in general

@SchrodingersGat
SchrodingersGat merged commit 6ba777d into inventree:master Jun 13, 2023
@SchrodingersGat
SchrodingersGat deleted the build-order-lines branch June 13, 2023 10:18
SchrodingersGat added a commit to inventree/demo-dataset that referenced this pull request Jun 13, 2023
- Migrate data to include new BuildLine model
- Ref: inventree/InvenTree#4855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API breaking Indicates a major update or change which breaks compatibility build Build orders enhancement This is an suggested enhancement or new feature migration Data or schema migrations refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve query efficiency for "required for build orders" Calculate overage in build allocation

2 participants