-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for fulfilling an order when product quantity equals allocated qu…
…antity (#6333) * Fix for fulfilling an order when product quantity equals allocated quantity * Add tests, update the CHANGELOG.md, modify schema objects * Style improvements * Add data loader, add permission decorator, style changes * Changes after code review
- Loading branch information
Grzegorz Derdak
committed
Oct 30, 2020
1 parent
60dab6a
commit c1e0c1c
Showing
6 changed files
with
142 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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,17 @@ | ||
from collections import defaultdict | ||
|
||
from ...warehouse.models import Allocation | ||
from ..core.dataloaders import DataLoader | ||
|
||
|
||
class AllocationsByOrderLineIdLoader(DataLoader): | ||
context_key = "allocations_by_orderline_id" | ||
|
||
def batch_load(self, keys): | ||
allocations = Allocation.objects.filter(order_line__pk__in=keys) | ||
order_lines_to_allocations = defaultdict(list) | ||
|
||
for allocation in allocations: | ||
order_lines_to_allocations[allocation.order_line_id].append(allocation) | ||
|
||
return [order_lines_to_allocations[order_line_id] for order_line_id in keys] |
This file contains 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 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 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 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