changes
This commit is contained in:
parent
b8079ebf97
commit
5b4d6bf2b2
@ -578,7 +578,7 @@ path(
|
|||||||
name="estimate_detail",
|
name="estimate_detail",
|
||||||
),
|
),
|
||||||
path("sales/estimates/create/", views.create_estimate, name="estimate_create"),
|
path("sales/estimates/create/", views.create_estimate, name="estimate_create"),
|
||||||
path("sales/estimates/create/<int:pk>/", views.create_estimate, name="estimate_create_from_opportunity"),
|
path("sales/estimates/create/<slug:slug>/", views.create_estimate, name="estimate_create_from_opportunity"),
|
||||||
path(
|
path(
|
||||||
"sales/estimates/<uuid:pk>/estimate_mark_as/",
|
"sales/estimates/<uuid:pk>/estimate_mark_as/",
|
||||||
views.estimate_mark_as,
|
views.estimate_mark_as,
|
||||||
|
|||||||
@ -3592,7 +3592,7 @@ class EstimateListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
|
|||||||
# @csrf_exempt
|
# @csrf_exempt
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required("django_ledger.add_estimatemodel", raise_exception=True)
|
@permission_required("django_ledger.add_estimatemodel", raise_exception=True)
|
||||||
def create_estimate(request, pk=None):
|
def create_estimate(request, slug=None):
|
||||||
"""
|
"""
|
||||||
Creates a new estimate based on the provided data and saves it. This function processes
|
Creates a new estimate based on the provided data and saves it. This function processes
|
||||||
a POST request and expects a JSON payload containing details of the estimate such as
|
a POST request and expects a JSON payload containing details of the estimate such as
|
||||||
@ -3780,7 +3780,7 @@ def create_estimate(request, pk=None):
|
|||||||
|
|
||||||
opportunity_id = data.get("opportunity_id")
|
opportunity_id = data.get("opportunity_id")
|
||||||
if opportunity_id != "None":
|
if opportunity_id != "None":
|
||||||
opportunity = models.Opportunity.objects.get(pk=int(opportunity_id))
|
opportunity = models.Opportunity.objects.get(slug=opportunity_id)
|
||||||
opportunity.estimate = estimate
|
opportunity.estimate = estimate
|
||||||
opportunity.save()
|
opportunity.save()
|
||||||
|
|
||||||
@ -3799,9 +3799,10 @@ def create_estimate(request, pk=None):
|
|||||||
active=True
|
active=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if pk:
|
if slug:
|
||||||
opportunity = models.Opportunity.objects.get(pk=pk)
|
opportunity = models.Opportunity.objects.get(slug=slug)
|
||||||
customer = opportunity.customer
|
customer = opportunity.customer
|
||||||
|
form.fields['customer'].queryset = models.Customer.objects.filter(pk=customer.pk)
|
||||||
form.initial["customer"] = customer
|
form.initial["customer"] = customer
|
||||||
|
|
||||||
car_list = (
|
car_list = (
|
||||||
@ -3842,7 +3843,7 @@ def create_estimate(request, pk=None):
|
|||||||
}
|
}
|
||||||
for x in car_list
|
for x in car_list
|
||||||
],
|
],
|
||||||
"opportunity_id": pk if pk else None,
|
"opportunity_id": slug if slug else None,
|
||||||
"customer_count": entity.get_customers().count(),
|
"customer_count": entity.get_customers().count(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5576,6 +5577,11 @@ class OpportunityDetailView(LoginRequiredMixin, DetailView):
|
|||||||
context["tasks"] = models.Tasks.objects.filter(
|
context["tasks"] = models.Tasks.objects.filter(
|
||||||
content_type__model="opportunity", object_id=self.object.id
|
content_type__model="opportunity", object_id=self.object.id
|
||||||
)
|
)
|
||||||
|
context["upcoming_events"] = {
|
||||||
|
"schedules": self.object.lead.get_all_schedules().filter(
|
||||||
|
scheduled_at__gt=timezone.now()
|
||||||
|
),
|
||||||
|
}
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
{% if opportunity.estimate %}
|
{% if opportunity.estimate %}
|
||||||
<a class="dropdown-item" href="{% url 'estimate_detail' opportunity.estimate.pk %}">{{ _("View Quotation")}}</a>
|
<a class="dropdown-item" href="{% url 'estimate_detail' opportunity.estimate.pk %}">{{ _("View Quotation")}}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="dropdown-item" href="{% url 'estimate_create_from_opportunity' opportunity.pk %}">{{ _("Create Quotation")}}</a>
|
<a class="dropdown-item" href="{% url 'estimate_create_from_opportunity' opportunity.slug %}">{{ _("Create Quotation")}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
<li><a class="dropdown-item" href="{% url 'update_opportunity' opportunity.slug %}">Update Opportunity</a></li>
|
<li><a class="dropdown-item" href="{% url 'update_opportunity' opportunity.slug %}">Update Opportunity</a></li>
|
||||||
@ -77,26 +77,26 @@
|
|||||||
<h4 class="mb-5 d-flex align-items-center"><span class="d-inline-block lh-sm me-1" data-feather="link" style="height:16px;width:16px;"></span> {{ _("Upcoming Events")}}</h4>
|
<h4 class="mb-5 d-flex align-items-center"><span class="d-inline-block lh-sm me-1" data-feather="link" style="height:16px;width:16px;"></span> {{ _("Upcoming Events")}}</h4>
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="mb-4">
|
{% for event in upcoming_events.schedules %}
|
||||||
<div class="d-flex flex-wrap justify-content-between mb-2">
|
<table class="table table-sm table-borderless mb-4">
|
||||||
<h5 class="mb-0 text-body-highlight me-2">{{ _("Estimate") }}</h5>
|
<thead>
|
||||||
</div>
|
<tr>
|
||||||
{% if opportunity.estimate %}
|
<th scope="col">{{ _("Type") }}</th>
|
||||||
<a class="dropdown-item" href="{% url 'estimate_detail' opportunity.estimate.pk %}">{{ _("View Quotation")}}</a>
|
<th scope="col">{{ _("Purpose") }}</th>
|
||||||
{% else %}
|
<th scope="col">{{ _("Scheduled At") }}</th>
|
||||||
<p>{{ _("No Estimate") }}</p>
|
</tr>
|
||||||
{% endif %}
|
</thead>
|
||||||
</div>
|
<tbody>
|
||||||
<div class="mb-4">
|
<tr>
|
||||||
<div class="d-flex flex-wrap justify-content-between mb-2">
|
<td>{{ event.scheduled_type|capfirst }}</td>
|
||||||
<h5 class="mb-0 text-body-highlight me-2">{{ _("Invoice") }}</h5>
|
<td>{{ event.purpose }}</td>
|
||||||
</div>
|
<td>{{ event.scheduled_at|naturaltime|capfirst }}</td>
|
||||||
{% if opportunity.estimate.invoice %}
|
</tr>
|
||||||
<a class="dropdown-item" href="{% url 'invoice_detail' opportunity.estimate.invoice.pk %}">{{ _("View Invoice")}}</a>
|
</tbody>
|
||||||
{% else %}
|
</table>
|
||||||
<p>{{ _("No Invoice") }}</p>
|
{% empty %}
|
||||||
{% endif %}
|
<p>{{ _("No Invoice") }}</p>
|
||||||
</div>
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user