in operation add current

This commit is contained in:
javad committed 2026-06-11 11:34:57 +03:30
1 parent 3b26ee3f93
commit 333f990170
2 files changed
+37 -13

No files matched your search

@@ -2,16 +2,16 @@
{% load custom_tags %}
{% block storeBody %}
<p class="has-text-centered mt-2 mb-2 is-size-5 ">{{ storeO.store_name }}</p>
<p class="has-text-centered mt-2 mb-2 is-size-5 ">{{ storeO.store_name }}</p>
<table class="table m-auto has-text-centered table is-bordered is-striped is-narrow is-fullwidth mojodiTB ">
<table class="table m-auto has-text-centered table is-bordered is-striped is-narrow is-fullwidth mojodiTB">
<thead>
<tr>
<th>نام محصول</th>
<th>ورود</th>
<th>خروج</th>
<th>توضیحات</th>
<th>ناریخ</th>
<th>مانده در لحظه</th> <th>توضیحات</th>
<th>تاریخ</th>
</tr>
</thead>
<tfoot>
@@ -19,8 +19,8 @@
<th>نام محصول</th>
<th>ورود</th>
<th>خروج</th>
<th>توضیحات</th>
<th>ناریخ</th>
<th>مانده در لحظه</th> <th>توضیحات</th>
<th>تاریخ</th>
</tr>
</tfoot>
<tbody>
@@ -29,6 +29,9 @@
<td>{{ operation.Product.product_name }} </td>
<td>{{ operation.s_in }}</td>
<td>{{ operation.s_out }}</td>
<td class="has-text-weight-bold {% if operation.current_stock_at_time < 0 %}has-text-danger{% else %}has-text-dark{% endif %}">
{{ operation.current_stock_at_time }}
</td>
<td>{{ operation.desc }}</td>
<td>{{ operation.createdDT | toJalali }}</td>
</tr>
@@ -58,4 +61,4 @@
</ul>
{% endif %}
{% endblock %}
{% endblock %}
+27 -6
View File
@@ -599,8 +599,13 @@ def store(request, s_id):
def operations(request, s_id):
page = request.GET.get('page', 1)
productCategory = ProductCategory.objects.all()
storeO = StoreRoom.objects.get(id=s_id)
operationsList = ProductInStore.objects.filter(StoreRoom=storeO, year=1400).order_by('-createdDT')
storeO = get_object_or_404(StoreRoom, id=s_id)
# بهینه‌سازی کلیدی: استفاده از select_related برای جلوگیری از کندی و پر شدن RAM دیتابیس
operationsList = ProductInStore.objects.filter(
StoreRoom=storeO, year=1400
).select_related('Product').order_by('-createdDT')
paginator = Paginator(operationsList, 25)
try:
data_list = paginator.page(page)
@@ -609,16 +614,32 @@ def operations(request, s_id):
except EmptyPage:
data_list = paginator.page(paginator.num_pages)
data = {'storeO': storeO, 'operationsList': data_list, 's_id': s_id, 'productCategory': productCategory}
data = {
'storeO': storeO,
'operationsList': data_list,
's_id': s_id,
'productCategory': productCategory
}
return render(request, 'admin_panel/operations.html', data)
@login_required(login_url='/panel/p_login/')
@permission_required('admin_panel.ViewStore', raise_exception=True)
def operationProduct(request, s_id, p_id):
productCategory = ProductCategory.objects.all()
storeO = StoreRoom.objects.get(id=s_id)
operationsList = ProductInStore.objects.filter(StoreRoom=storeO, year=1400, Product__id=p_id).order_by('-createdDT')
data = {'storeO': storeO, 'operationsList': operationsList, 's_id': s_id, 'productCategory': productCategory}
storeO = get_object_or_404(StoreRoom, id=s_id)
# بهینه‌سازی کلیدی در فیلتر اختصاصی محصول
operationsList = ProductInStore.objects.filter(
StoreRoom=storeO, year=1400, Product__id=p_id
).select_related('Product').order_by('-createdDT')
data = {
'storeO': storeO,
'operationsList': operationsList,
's_id': s_id,
'productCategory': productCategory
}
return render(request, 'admin_panel/operations.html', data)
@login_required(login_url='/panel/p_login/')