Closed miggland closed 2 years ago
@miggland looks like this has stalled somewhat.. Any further work happening on this one soon?
I had some trouble with the syntax of creating shipments, and a lack of time. I'm just as not as productive as you guys ;) However, it's not completely stalled, just going slow..
@miggland looks like there is a pretty critical bug in the current python implementation which is preventing your attempts here to work (as per your discussion in https://github.com/inventree/InvenTree/discussions/3256).
Basically, for the POST
method we use data=...
rather than json=...
- this causes the data sent to the server to be encoded as a string rather than a JSON object. This appears to be OK for flat requests but nested ones fail!
Looking into this now
@miggland once https://github.com/inventree/inventree-python/pull/123 is merged, pull master back in to your branch and you should then be able to get it working
@miggland #123 is merged in now so you should be able to proceed with this. LMK if you need any assistance.
@miggland ther are still some style issues but looks great otherwise!
Thanks @matmair . The tests are quite working yet either.. I'll get there though! :D
This should allow retrieving the allocated items as well.
This part is covered by 'allocations' field in Shipment item.
@miggland that is normal for working with a new code base. You are down to 1 error so it is looking good. If you require assistance feel free to ping inventree/maintainer inventree/triage
Finally - I'm going to let you review this now, see if you agree with the approach taken.
There are two ways to allocate Items - the simplest way is via the SalesOrderLineItem.allocateToShipment()
method, which should be supplied with at least a Shipment object. Further options include limiting which stock items to choose from.
The alternative, which requires defining the items-dict, is to the use the SalesOrderShipment.allocateItems()
@miggland looks like a really solid implementation :)
Only request is to add some unit testing for the SalesOrderLineItem.allocateToShipment
method - currently this is not being tested.
@miggland LMK if you can add this small extra unit test 👍
I will
I broke another test oops
I broke another test oops
Not sure what you did, though.. That test does not seem related to your code at all!
Could one of those stock items have been depleted, and automatically deleted, because I assigned and shipped them?
Ah, good call! That is probably what is happening :) Probably best to change the test to >= 19
as we cannot guarantee what order the tests run in.
If you say that's OK, sounds like a simple fix :)
Funnily, this test didn't fail on my test machine.
Thanks for the fixes, and for your continued contributions :)
@miggland nice landing! FYI: I am not even running the tests on my machine anymore. Just code, run through the thing you changed and let GitHub do its thing - that way you can work on something else meanwhile 😇
Just to let you know I'm working on adding the basic Shipment functionality to the python binding. This is a contribution to #90.
Basic functions include:
This should allow retrieving the allocated items as well.