From ee8d8cf2878e85b27251d7c3b011da480aede93e Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Tue, 2 Sep 2025 16:29:18 +0300 Subject: [PATCH] bill queryset resolved --- inventory/templatetags/custom_filters.py | 7 ++++++- templates/bill/tags/bill_item_formset.html | 14 ++------------ templates/ledger/reports/purchase_report.html | 6 +++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index f096dcf0..17832ab4 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -494,8 +494,13 @@ def po_item_formset_table(context, po_model, itemtxs_formset, user): @register.inclusion_tag("bill/tags/bill_item_formset.html", takes_context=True) def bill_item_formset_table(context, item_formset): bill = BillModel.objects.get(uuid=context["view"].kwargs["bill_pk"]) - for item in item_formset: + for form in item_formset.forms: + form.fields["item_model"].queryset = form.fields["item_model"].queryset.exclude( + item_role="product" + ) + for item in item_formset: if item: + print(item.fields["item_model"]) item.initial["quantity"] = item.instance.po_quantity item.initial["unit_cost"] = item.instance.po_unit_cost # print(item.instance.po_quantity) diff --git a/templates/bill/tags/bill_item_formset.html b/templates/bill/tags/bill_item_formset.html index eb0d0c55..cd26fb00 100644 --- a/templates/bill/tags/bill_item_formset.html +++ b/templates/bill/tags/bill_item_formset.html @@ -2,19 +2,9 @@ {% load static %} {% load django_ledger %} {% load widget_tweaks %} -{% if bill.get_itemtxs_data.1.total_amount__sum > 0 %}
- {% else %} - - {% endif %}
@@ -125,13 +115,13 @@
- {% if not item_formset.has_po %} + {% comment %} {% if not item_formset.has_po %} {% trans 'New Item' %} - {% endif %} + {% endif %} {% endcomment %}