-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
Add ability to modify a completed build #977
Comments
This is a great idea, and I have been thinking about how to implement something like this for quite some time.
It "simply" needs to be implemented! Background Reading: - #918 For this to work, the first step is to implement the concept of "installing" a StockItem inside another StockItem (e.g. track a single serialized item inside another). Currently this does not work - a "build" captures much more generic information about stock items that go into a particular build. But it does not currently record which particular unique items were assigned to which particular build outputs.
|
I can see the required UI elements to facilitate "uninstalling" parts from a build (especially when the build has multiple outputs) becoming quite complex. But, probably necessarily complex (I don't see a way of avoiding it really). At a "minimum" I think there needs to be ways for the user to:
I think that "modifying" a build is much the same as unallocating parts, with the difference being that these need to be "uninstalled" from the output parts. |
Hi @SchrodingersGat , |
I have been thinking about this over the weekend, and I think I have a potential solution which is a bit more generic, particularly in terms of allowing multiple build outputs for a build. This is a feature which I know would be of great use to my workplace, where we make parts in "batches" and might have 20-50 unique outputs in a single build. The following thoughts relate to this PR and also to #993 and #991 The current way that a build is intended to work is that after the build is complete, a new stock item is generated, and any allocated items are then removed from stock and installed in the new stockitem. (Note: currently this is not actually the case, the allocated items are instead allocated to the build, not the generated output stockitem). A new approach would be to create the new stock items immediately (when the build is created). The allocation process allocates sub-items to the new stockitems, and not the build object.
Allocating StockIn terms of how stock gets allocated: Non-Trackable PartsNon-trackable parts can be allocated semi-automatically in much the same way they are currently. It does not particularly matter which parts are installed into a given output. Trackable PartsSub-parts marked as trackable must be manually and individually installed into the generated stock items. This forces the user to pick which serialized stock items are installed into which output stock item. User InterfaceThe UI would not actually have to change that much with this approach. Instead of having a single table for allocation of stock to the build, there would be a copy of this table for each "output" of the build. Each table would have a progress bar indicating how much of the allocation has been completed. Each "output" would be minimized when completed, and can be expanded to see which stock have been allocated. Something like this I'm not yet 100% across your changes, but it did get me thinking how a generic solution could be implemented. Let me know if you have any thoughts on this. It would be a pretty big change, especially having to consider how to migrate from the existing way that builds are managed... |
@SchrodingersGat , I think that approach makes sense for the initial builds/installing. I really like the "uninstall" feature that you added onto the build items.
-Alex |
I think that the "Build" process controls what happens during a build, and then generates one or more output stock items (which will have other stock items installed in them). Once the Build process is finished, any "uninstallation" of installed stock items is not really part of the build process, as the build order has been completed. However, there should be an easy way to either uninstall items from a parent item (which has now been implemented) and in a similar fashion, a simple way to install more items. Here's one way I can imagine that happening: In the "Installed Items" tab for a given stock item, in addition to showing rows for each installed stock item, we can add rows for each "part" in the BOM. This way, we can see if any BOM items have not been installed (or have been installed and then uninstalled) and thus how "complete" this part is.
Here's a very rough mockup:
I am currently working on this manual install / uninstall table, to make the changes as roughly detailed above. I'll @ you in the PR so you can test it out. The other big change is to the Build process, which will generate stock items at the start of the build process, but mark them as "building". That will require the following changes:
If there are any steps in that list that you want to tackle (and I guess the development order is roughly top to bottom) then let me know. I'm happy to provide pointers if you need. This feature is the next-most-useful feature for me too, so I'm keen to get it working correctly. Implementing this solution will close out a lot of outstanding issues too, so I'm very happy about that :) |
Sounds great! I can try and make some progress on that list of todos tomorrow. Is there a branch I should work from or is master recent enough? |
I have a specific question you could probably help me with: |
There's a lot of places where this could be achieved, some "better" than others. I'm still learning a lot about the "django way" to do things and so you'll no doubt find many functions in the InvenTree code base that perform the same task in wildly different ways. Some context here would help, I think.
You can handle this either in the form class, or in the view class which handles the form. Depending on whether the actions are to do with form validation, or back-end database actions, will somewhat determine the "best" answer here. But walk me through what exactly you're trying to do and I'm sure we can work something out. |
This would be relevant for creating the stock items of the build outputs at the time of build creation and specifically once the user has successfully submitted a valid "Create Build Form." I think I would want it to run after the form is validated and before the model is saved (since I want to add information to the model). Any suggestions? |
Check out the AjaxCreateView class which offers I think you would actually want to perform this step after saving the Build object, as you need to point the generated stockitem objects to the build. e.g. # After build item has been saved
build = get_object()
# Create some stock items
for i in range(build.quantity):
StockItem.objects.create(
part=build.part,
quantity=1,
is_building=True
)
# This will automatically link the new stockitem objects to the build object using the 'build_outputs' lookup
outputs = build.build_outputs.all() |
Didn't have as much time today as I hoped but I started #1021 to log the changes I've made so far. Trying to keep each commit isolated enough to reference the line items you had listed above. |
Hi there! I am hoping to use Inventree for keeping an inventory of hardware components but there is a feature that I need which is not currently implemented.
An example of the use case:
From messing around the code base a bit, it seems that every time the build is moved from "Pending" to "Completed", it makes a new build output. I would imagine some business logic needs to be added to handle this scenario.
Is this a use-case Inventree purposely does not want to allow or does it just need to be coded up? I'm new to django but wouldn't mind giving this a try if I'm aware of the common pitfalls when adding a feature like this.
The text was updated successfully, but these errors were encountered: