add sa import and hide the button in the po update page

This commit is contained in:
ismail 2025-06-26 19:23:34 +03:00
parent c4a57f4803
commit 1e7ed1f88d
4 changed files with 27 additions and 26 deletions

View File

@ -1091,7 +1091,7 @@ class CarListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
"sold": cars.filter(status="sold").count(),
"transfer": cars.filter(status="transfer").count(),
}
context["make"] = models.CarMake.objects.filter(car__in=cars).distinct()
context["make"] = models.CarMake.objects.filter(is_sa_import=True,car__in=cars).distinct()
context["model"] = models.CarModel.objects.none()
context["year"] = models.Car.objects.none()
make = self.request.GET.get("make")
@ -1573,7 +1573,7 @@ class CarDeleteView(
model = models.Car
template_name = "inventory/car_confirm_delete.html"
permission_required = ["inventory.delete_car"]
def delete(self, request, *args, **kwargs):
@ -1584,14 +1584,14 @@ class CarDeleteView(
Returns the URL to redirect to after a successful car deletion.
It dynamically includes the dealer_slug from the URL.
"""
dealer_slug = self.kwargs.get('dealer_slug')
if dealer_slug:
return reverse_lazy("car_list", kwargs={'dealer_slug': dealer_slug})
else:
messages.error(self.request, _("Could not determine dealer for redirection."))
return reverse_lazy("home")
return reverse_lazy("home")
class CarLocationCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
@ -2068,7 +2068,7 @@ class DealerDetailView(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
dealer = self.object
car_makes = models.CarMake.objects.filter(car_dealers__dealer=dealer)
car_makes = models.CarMake.objects.filter(car_dealers__dealer=dealer,is_sa_import=True)
staff_count = dealer.staff_count
cars_count = models.Car.objects.filter(dealer=dealer).count()
@ -9251,7 +9251,7 @@ def InventoryItemCreateView(request, dealer_slug):
form = forms.CSVUploadForm()
form.fields["vendor"].queryset = dealer.vendors.filter(active=True)
context = {
"make_data": models.CarMake.objects.all(),
"make_data": models.CarMake.objects.filter(is_sa_import=True),
"inventory_accounts": inventory_accounts,
"cogs_accounts": cogs_accounts,
"form": form,
@ -9261,7 +9261,7 @@ def InventoryItemCreateView(request, dealer_slug):
request,
"purchase_orders/inventory_item_form.html",
{
"make_data": models.CarMake.objects.all(),
"make_data": models.CarMake.objects.filter(is_sa_import=True),
"inventory_accounts": inventory_accounts,
"cogs_accounts": cogs_accounts,
},
@ -9535,7 +9535,7 @@ class PurchaseOrderMarkAsApprovedView(BasePurchaseOrderActionActionView):
class PurchaseOrderMarkAsFulfilledView(BasePurchaseOrderActionActionView):
action_name = "mark_as_fulfilled"
class PurchaseOrderMarkAsCanceledView(BasePurchaseOrderActionActionView):
action_name = "mark_as_canceled"

View File

@ -96,7 +96,6 @@
</div>
</div>
<div class="form-group">
<label for="account">Account</label>
<select class="form-control" name="account" id="account">

View File

@ -3,19 +3,19 @@
{% block content %}
<form action="{% url 'inventory_item_create' request.dealer.slug po_model.pk %}" method="post">
<form action="{% url 'inventory_item_create' request.dealer.slug po_model.pk %}" method="post">
{% csrf_token %}
{% include "purchase_orders/partials/po-select.html" with name="make" target="model" data=make_data pk=po_model.pk %}
{% include "purchase_orders/partials/po-select.html" with name="model" target="serie" data=model_data pk=po_model.pk %}
{% include "purchase_orders/partials/po-select.html" with name="serie" target="trim" data=serie_data pk=po_model.pk %}
{% include "purchase_orders/partials/po-select.html" with name="trim" target="none" data=trim_data pk=po_model.pk %}
<div class="form-group">
<label for="account">Account</label>
<select class="form-control" name="account" id="account">
{% for account in inventory_accounts %}
<option value="{{ account.pk }}">{{ account }}"></option>
{% endfor %}
</select>
<label for="account">Account</label>
<select class="form-control" name="account" id="account">
{% for account in inventory_accounts %}
<option value="{{ account.pk }}">{{ account }}"></option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="quantity">Quantity</label>

View File

@ -20,16 +20,18 @@
<tr>
<th class="d-flex justify-content-between align-items-center">
{% trans 'Item' %}
{% if po_model.is_draft %}
<button type="button"
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'inventory_item_create' dealer_slug %}?for_po=1"
hx-target=".main-modal-body"
hx-select="form"
hx-swap="innerHTML">
<i class="fas fa-plus me-1"></i>{% trans 'Add Item' %}
</button>
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'inventory_item_create' dealer_slug %}?for_po=1"
hx-target=".main-modal-body"
hx-select="form"
hx-swap="innerHTML">
<i class="fas fa-plus me-1"></i>{% trans 'Add Item' %}
</button>
{% endif %}
</th>
<th>{% trans 'Unit Cost' %}</th>
<th>{% trans 'Quantity' %}</th>