-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Stock parameters #11459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SchrodingersGat
wants to merge
8
commits into
inventree:master
Choose a base branch
from
SchrodingersGat:stock-parameters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Stock parameters #11459
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
382eaf6
Allow parameters for StockItem objects
SchrodingersGat 2590427
Update API serializer
SchrodingersGat d934385
Implement frontend panel
SchrodingersGat 3382833
Add parametric view for stock items
SchrodingersGat ebce83c
Docs updates
SchrodingersGat b242016
Additional playwright tests
SchrodingersGat 643c7be
Bump API version
SchrodingersGat 874b316
Update CHANGELOG
SchrodingersGat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/frontend/src/tables/stock/ParametricStockItemTable.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { ApiEndpoints, ModelType } from '@lib/index'; | ||
| import type { TableFilter } from '@lib/types/Filters'; | ||
| import type { TableColumn } from '@lib/types/Tables'; | ||
| import { t } from '@lingui/core/macro'; | ||
| import { useMemo } from 'react'; | ||
| import { | ||
| DescriptionColumn, | ||
| IPNColumn, | ||
| PartColumn, | ||
| StockColumn | ||
| } from '../ColumnRenderers'; | ||
| import ParametricDataTable from '../general/ParametricDataTable'; | ||
|
|
||
| export default function ParametricStockItemTable({ | ||
| locationId | ||
| }: Readonly<{ | ||
| locationId?: any; | ||
| }>) { | ||
| const customFilters: TableFilter[] = useMemo(() => { | ||
| // Custom filters for the parametric stock item table | ||
| return []; | ||
| }, []); | ||
|
|
||
| const customColumns: TableColumn[] = useMemo(() => { | ||
| return [ | ||
| PartColumn({ | ||
| part: 'part_detail', | ||
| switchable: false | ||
| }), | ||
| IPNColumn({}), | ||
| DescriptionColumn({ | ||
| accessor: 'part_detail.description' | ||
| }), | ||
| StockColumn({ | ||
| accessor: '', | ||
| title: t`Stock`, | ||
| sortable: true, | ||
| ordering: 'stock' | ||
| }) | ||
| ]; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <ParametricDataTable | ||
| modelType={ModelType.stockitem} | ||
| relatedModel={'location'} | ||
| relatedModelId={locationId} | ||
| endpoint={ApiEndpoints.stock_item_list} | ||
| customColumns={customColumns} | ||
| customFilters={customFilters} | ||
| queryParams={{ | ||
| location: locationId, | ||
| cascade: true, | ||
| location_detail: true, | ||
| part_detail: true | ||
| }} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just applying the default business logic for parameters and parameter template <> stock item is not really intuitive.
As far as I can see this just enabled parameters but no mechanisms to handle the splitting / merging of stock items (as regularly happens) and what should happen to parameters in that case. That leaves holes compared to the default usage flow for stock items.
Was this considered, and should this limitation be documented or addressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll chime in since I started the discussion thread. FWIW, I didn't consider stock splitting/merging. I avoid using merging at all in my workflow due to it destroying history in the merge. Since merging is already destructive, I'd vote that the "winning" stock item retains its original parameters as with the rest of history and document that. That's just my $0.02.
Splitting is an interesting, and I'd say new, case. For my use cases I'd expect split items to inherit their parents' parameters. Now that raises the question is it a one-time copy-on-split, or do child stock items dynamically inherit their parents parameters? I honestly don't have a good opinion on this and it feels like this has nuance depending on use case. Either way, I'd expect stock items to inherit parent parameters via some method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought more about this, and my vote is to do a "copy-on-split" of params into the split child stock item. new/changed params on the parent after that time don't reflect in the child. I think that is both most clear to document and implement. Again, just my $0.02.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I may, as the second requester: merging stock can be blocked altogether if there are custom parameters present that have different values, same as there are options to block for mismatched suppliers and states.