forked from botswana-harvard/edc-pharmacy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
945 additions
and
103 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
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
22 changes: 22 additions & 0 deletions
22
edc_pharmacy/admin/actions/print_transfer_stock_manifest.py
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,22 @@ | ||
from __future__ import annotations | ||
|
||
from django.contrib import admin, messages | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext | ||
|
||
|
||
@admin.action(description="Print transfer manifest") | ||
def print_transfer_stock_manifest_action(modeladmin, request, queryset): | ||
if queryset.count() > 1 or queryset.count() == 0: | ||
messages.add_message( | ||
request, | ||
messages.ERROR, | ||
gettext("Select one and only one item"), | ||
) | ||
else: | ||
url = reverse( | ||
"edc_pharmacy:generate_manifest", kwargs={"stock_transfer": queryset.first().pk} | ||
) | ||
return HttpResponseRedirect(url) | ||
return None |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from django.contrib import admin | ||
|
||
from ...admin_site import edc_pharmacy_admin | ||
from ...models import StockProxy | ||
from ..list_filters import TransferredListFilter | ||
from .stock_admin import StockAdmin | ||
|
||
|
||
@admin.register(StockProxy, site=edc_pharmacy_admin) | ||
class StockProxyAdmin(StockAdmin): | ||
|
||
list_display = ( | ||
"formatted_code", | ||
"transferred", | ||
"formatted_confirmed_at_site", | ||
"formatted_dispensed", | ||
"stock_request_changelist", | ||
"stock_transfer_item_changelist", | ||
"allocation_changelist", | ||
"dispense_changelist", | ||
"formulation", | ||
"qty", | ||
"container_str", | ||
"unit_qty", | ||
"created", | ||
"modified", | ||
) | ||
list_filter = ( | ||
TransferredListFilter, | ||
"confirmed_at_site", | ||
"product__formulation__description", | ||
"location__display_name", | ||
"created", | ||
"modified", | ||
) | ||
search_fields = ( | ||
"stock_identifier", | ||
"from_stock__stock_identifier", | ||
"code", | ||
"from_stock__code", | ||
"repack_request__id", | ||
"allocation__registered_subject__subject_identifier", | ||
"allocation__stock_request_item__id", | ||
"allocation__stock_request_item__stock_request__id", | ||
"allocation__id", | ||
"stocktransferitem__stock_transfer__id", | ||
) | ||
readonly_fields = ( | ||
"code", | ||
"confirmed", | ||
"confirmed_by", | ||
"confirmed_datetime", | ||
"container", | ||
"from_stock", | ||
"location", | ||
"repack_request", | ||
"lot", | ||
"product", | ||
"qty_in", | ||
"qty_out", | ||
"unit_qty_in", | ||
"unit_qty_out", | ||
"receive_item", | ||
"stock_identifier", | ||
) | ||
|
||
def get_queryset(self, request): | ||
return ( | ||
super() | ||
.get_queryset(request) | ||
.filter(confirmed=True, allocation__isnull=False, container__may_request_as=True) | ||
) |
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
Oops, something went wrong.