Repository navigation
Transfer Order - #11281
Transfer Order#11281
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
matmair
left a comment
There was a problem hiding this comment.
Very good start; looking at this we might want to change how a few parts of the code base work, this seems much to complicated for someone new to wrap their head around. Thanks for doing so still
| return sum([ | ||
| self.build_order_allocation_count(**kwargs), | ||
| self.sales_order_allocation_count(**kwargs), | ||
| self.transfer_order_allocation_count(**kwargs), |
There was a problem hiding this comment.
are we sure we want to include this here?
There was a problem hiding this comment.
I'm not sure. This starts to creep in my question about whether we want to consider stock allocated to a Transfer Order as "available" or not, which also impacts the "required quantity"
There was a problem hiding this comment.
It is an interesting question. I think that stock which is "in transfer" is not necessarily "unavailable" - merely moving from one location to another?
Alternatively if they are "unavailable" until the transfer order is complete, this also could make sense because it precludes them being assigned elsewhere (until the transfer is completed)
There was a problem hiding this comment.
Here's an argument against including "reduced availability" logic for Transfer Orders.....
The spot it hurts most is actually not at the part allocation counts, referenced here, but at the stock item allocation count in StockItemSerializer.annotate_queryset(). The part level allocation counts at least are "released" once the order is no longer "pending", as defined by TransferOrderStatusGroups and Part.transfer_order_allocations()
However, if I don't clear allocations, the available stock remains reduced even after the order completes from the point of view of the stock item.
@staticmethod
def annotate_queryset(queryset):
....
# Annotate the queryset with the total allocated to sales orders
queryset = queryset.annotate(
allocated=Coalesce(
SubquerySum('sales_order_allocations__quantity'), Decimal(0)
)
# THIS IS THE PROBLEMATIC LINE!
# this count isn't 'released' after the TO completes,
# forever reducing available qty for a stock item that has been through a TO
+ Coalesce(SubquerySum('transfer_order_allocations__quantity'), Decimal(0))
+ Coalesce(SubquerySum('allocations__quantity'), Decimal(0))
)And since in the current implementation, the TransferOrderAllocation is the only thing attaching a StockItem to a TransferOrder, if I clear allocations on complete, I lose the reference for which stock was transferred from this order.
In lieu of a more sophisticated immutable tracking on the transfer order - which I'm beginning to think is more scope than I'm willing to commit to in this PR - I think excluding TO allocations from any availability calculations is best, and then revisit when/if the immutable tracking exists.
|
I'll be on vacation for the next 10 days, so won't be working on this until I'm back. Before spending any more serious time on it when I return, I'd like to hear from your perspective what should be my priorities before this can be merged. I've detailed some of my thoughts in the PR description. The basic functionality present is probably enough for me to start using it on my instance - maybe behind a feature flag - but I know there's a lot of housekeeping left to do before it could be considered "official." |
Documentation@jacobfelknor this will need to also have comprehensive docs added, under the "stock" master docs location :) |
SchrodingersGat
left a comment
There was a problem hiding this comment.
@jacobfelknor this is a really good implementation, great effort!
| return sum([ | ||
| self.build_order_allocation_count(**kwargs), | ||
| self.sales_order_allocation_count(**kwargs), | ||
| self.transfer_order_allocation_count(**kwargs), |
There was a problem hiding this comment.
It is an interesting question. I think that stock which is "in transfer" is not necessarily "unavailable" - merely moving from one location to another?
Alternatively if they are "unavailable" until the transfer order is complete, this also could make sense because it precludes them being assigned elsewhere (until the transfer is completed)
|
@jacobfelknor I've fixed a bunch of conflict issues here - I think there are just a couple of the new playwright tests which are not passing. If you can get to these soon, that would be great! Otherwise, we might start to see more conflicts again which adds difficulty |
|
On it |
|
I think I've fixed an issue with the transfer order test.... I was able to see a case every now and then where the allocation form hadn't finished its API request to populate the stock item dropdown before it tried to proceed. Hopefully 479a1c5 helps this. I wasn't able to reproduce the Build Order output test that also failed previously |
|
I also was assuming the test would only be ran once per pipeline, but I'm not sure that is true. 1afbd0b duplicates the transfer order I complete before running so that it can be ran many times in a row without issues |
|
I'm stuck.... I can't reproduce these failures locally |
The order of tests can also not be guaranteed. It's a good idea to try and design the tests to be idempotent, as far as possible |
|
@jacobfelknor all passing now! @matmair I'm happy with this, are you happy for this to be merged? |
|
Thanks for the assist 😁 |
|
Great effort, this is ready for merge! There surely will be follow ups once users get access and discover new ways to use this but I think this is pretty well rounded as-is. |
|
@matmair due to the large schema diff, the "schema push" action has failed - can you manually fix this? |
|
on it @SchrodingersGat |
* initial skel commit for transfer orders * initial transfer order backend model * add some serializers, rename PLACED to ISSUED for TransferOrders * adding from admin console works * simple table list almost working, but we need to add order line items.... * add other cols to table * add Transfer Order from table view * moving towards a detail view * wip: adding detail view * add take from and destination serializer details * add other detail grid items * edit/duplicate transfer order * more action buttons * first crack at adding line items * add to line item * add filters * starting work on row actions * more action buttons for line items * fix copy lines in duplicate * basic allocation works * allocations table actions * allocate serials * allocated serial row expansion * add transferred qty to serializers * move items on complete, show in tracking * change panel to transferred stock upon complete * allow incomplete line items * disable edit allocations when completed * add ref pattern and to settings * add admin to line item inline * add calendar and parametric view * basic transfer order report * add transfer order ruleset * starting allocation buisness logic throughout for TOs * disable accept incomplete logic, which was incorrect, until I fix * fix incomplete allocation option * add transferred col to default report * add transfer order to calendar ics view * chain condition for readability * add transfer order allocations table to stockitem view * don't account TO allocations in availability * add transfer orders table for a part * 'consume' option by doing take_stock * squash migrations * starting to test transfer order * more transfer order tests * add transfer order consume test * wip, more tests * more transfer order tests * had to refresh_from_db * switch "to" to "transfer-order" in url paths * only select non-virtual parts from transfer order * add transfer order docs * deconflict migrations * fix frontend build error * fix validation on transfer order reference pattern * add oath2 scope for transfer order * fix state test to include transfer order state * add barcode_model_type_code for transfer order * bump api version * check view role for transfer order, remove debug/commented out lines * add serialized allocation test * Fix migrations * Frontend fixes * Implement required 'company' attribute * transfer order report context * attempt to fix tests * delete transfer order allocations on cancel * add a few playwright tests, more incoming * more playwright * add source and destination locations to table * deconflict migrations * Fix build issue * attempt to fix flaky transfer order test * duplicate transfer order before running tests * Adjust playwright tests * Fix migration dependency order --------- Co-authored-by: Oliver <[email protected]> Co-authored-by: Matthias Mair <[email protected]>
* initial skel commit for transfer orders * initial transfer order backend model * add some serializers, rename PLACED to ISSUED for TransferOrders * adding from admin console works * simple table list almost working, but we need to add order line items.... * add other cols to table * add Transfer Order from table view * moving towards a detail view * wip: adding detail view * add take from and destination serializer details * add other detail grid items * edit/duplicate transfer order * more action buttons * first crack at adding line items * add to line item * add filters * starting work on row actions * more action buttons for line items * fix copy lines in duplicate * basic allocation works * allocations table actions * allocate serials * allocated serial row expansion * add transferred qty to serializers * move items on complete, show in tracking * change panel to transferred stock upon complete * allow incomplete line items * disable edit allocations when completed * add ref pattern and to settings * add admin to line item inline * add calendar and parametric view * basic transfer order report * add transfer order ruleset * starting allocation buisness logic throughout for TOs * disable accept incomplete logic, which was incorrect, until I fix * fix incomplete allocation option * add transferred col to default report * add transfer order to calendar ics view * chain condition for readability * add transfer order allocations table to stockitem view * don't account TO allocations in availability * add transfer orders table for a part * 'consume' option by doing take_stock * squash migrations * starting to test transfer order * more transfer order tests * add transfer order consume test * wip, more tests * more transfer order tests * had to refresh_from_db * switch "to" to "transfer-order" in url paths * only select non-virtual parts from transfer order * add transfer order docs * deconflict migrations * fix frontend build error * fix validation on transfer order reference pattern * add oath2 scope for transfer order * fix state test to include transfer order state * add barcode_model_type_code for transfer order * bump api version * check view role for transfer order, remove debug/commented out lines * add serialized allocation test * Fix migrations * Frontend fixes * Implement required 'company' attribute * transfer order report context * attempt to fix tests * delete transfer order allocations on cancel * add a few playwright tests, more incoming * more playwright * add source and destination locations to table * deconflict migrations * Fix build issue * attempt to fix flaky transfer order test * duplicate transfer order before running tests * Adjust playwright tests * Fix migration dependency order --------- Co-authored-by: Oliver <[email protected]> Co-authored-by: Matthias Mair <[email protected]>

Add a Transfer Order to InvenTree which is based on other order types, such as a Sales Order.
Done:
TRANSFERORDER_ENABLED,TRANSFERORDER_REFERENCE_PATTERN, andTRANSFERORDER_REQUIRE_RESPONSIBLEDifferences between Transfer Order and other Orders
Items I'd still like to explore
Adding a "consume" option which consumes stock against an order rather than moving it.
Immutable tracking on the transfer.
Similarly to BO's "consume stock" feature, it may be nice to execute the Transfer Order in smaller increments. We could add a "transfer now" feature to allocated stock, doing partial transfers before the entire order is complete
add a Transfer Order Allocations table to the stock item Allocations panel
unit testing
documentation
General questions
IN_STOCK_FILTERwould need to account for transfer orders in this caseTesting