Merge pull request 'bill queryset resolved.' (#221) from frontend into main
Reviewed-on: #221
This commit is contained in:
commit
0b92c7a9e6
@ -494,10 +494,15 @@ 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:
|
||||
item.initial["quantity"] = item.instance.po_quantity
|
||||
item.initial["unit_cost"] = item.instance.po_unit_cost
|
||||
print(item.fields["item_model"])
|
||||
item.initial["quantity"] = item.instance.po_quantity if item.instance.po_quantity else item.instance.quantity
|
||||
item.initial["unit_cost"] = item.instance.po_unit_cost if item.instance.po_unit_cost else item.instance.unit_cost
|
||||
# print(item.instance.po_quantity)
|
||||
# print(item.instance.po_unit_cost)
|
||||
# print(item.instance.po_total_amount)
|
||||
|
||||
@ -2,19 +2,9 @@
|
||||
{% load static %}
|
||||
{% load django_ledger %}
|
||||
{% load widget_tweaks %}
|
||||
{% if bill.get_itemtxs_data.1.total_amount__sum > 0 %}
|
||||
<form id="bill-update-form"
|
||||
action="{% url 'bill-update-items' dealer_slug=dealer_slug entity_slug=entity_slug bill_pk=bill_pk %}"
|
||||
method="post">
|
||||
{% else %}
|
||||
<form id="bill-update-form"
|
||||
hx-trigger="load delay:300ms"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#bill-update-form"
|
||||
hx-select="#bill-update-form"
|
||||
hx-post="{% url 'bill-update-items' dealer_slug=dealer_slug entity_slug=entity_slug bill_pk=bill_pk %}"
|
||||
method="post">
|
||||
{% endif %}
|
||||
<div class="container-fluid py-4">
|
||||
<!-- Page Header -->
|
||||
<div class="row mb-4">
|
||||
@ -125,13 +115,13 @@
|
||||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-start gap-2">
|
||||
{% if not item_formset.has_po %}
|
||||
{% comment %} {% if not item_formset.has_po %}
|
||||
<a href="{% url 'django_ledger:product-create' entity_slug=entity_slug %}"
|
||||
class="btn btn-phoenix-primary">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
{% trans 'New Item' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %} {% endcomment %}
|
||||
<button type="submit" class="btn btn-phoenix-primary">
|
||||
<i class="fas fa-save me-1"></i>
|
||||
{% trans 'Save Changes' %}
|
||||
|
||||
@ -50,15 +50,15 @@
|
||||
{% trans 'Filters' %} <i class="fas fa-sliders-h ms-2"></i>
|
||||
</h2>
|
||||
<form method="GET" class="row g-3 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<label for="start_date" class="form-label">{% trans 'Start Date' %}</label>
|
||||
<input type="date" class="form-control" id="start_date" name="start_date" value="{{ start_date|default_if_none:'' }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<label for="end_date" class="form-label">{% trans 'End Date' %}</label>
|
||||
<input type="date" class="form-control" id="end_date" name="end_date" value="{{ end_date|default_if_none:'' }}">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<i class="fas fa-filter me-2"></i>{% trans 'Filter' %}
|
||||
</button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user