Loading stock item after creation and fixed form validation for 'dynamic' supplier part #936
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.
@SchrodingersGat I am not sure the behavior was intentional but after creating a stock item, there would be no redirect and the Stock index was shown and not updated. Instead I thought it would be better to show the newly created stock item, like it is showing the part details after a part creation.
Second thing, it looks like the new "dynamic" fields (#934) prevent form validation when reloaded and there is no further user interaction. Using the create stock item modal form, I was trying to select a Base part only and it would not validate the "supplier part". After immediately re-submitting, it would validate.
The way I fixed it was to remove the "supplier part" field from the form if user has not selected any item (eg. still at the default value
------
). I am not sure what could be a better way, I tried to overwrite the "supplier part" field in the Form instance with aModelChoiceField
and therequired=False
argument but it still wouldn't validate...