diff --git a/inventory/models.py b/inventory/models.py index 9568609d..80ecd91a 100644 --- a/inventory/models.py +++ b/inventory/models.py @@ -2448,12 +2448,7 @@ class Opportunity(models.Model): null=True, blank=True, ) - probability = models.PositiveIntegerField(validators=[validate_probability],null=True, blank=True) - amount = models.DecimalField( - max_digits=10, - decimal_places=2, - verbose_name=_("Amount"), - ) + expected_revenue = models.DecimalField( max_digits=10, decimal_places=2, @@ -2461,8 +2456,6 @@ class Opportunity(models.Model): blank=True, null=True, ) - vehicle_of_interest_make = models.CharField(max_length=50, blank=True, null=True) - vehicle_of_interest_model = models.CharField(max_length=100, blank=True, null=True) expected_close_date = models.DateField(blank=True, null=True) created = models.DateTimeField(auto_now_add=True, verbose_name=_("Created")) updated = models.DateTimeField(auto_now=True, verbose_name=_("Updated")) @@ -2523,8 +2516,6 @@ class Opportunity(models.Model): return objects def save(self, *args, **kwargs): - if self.amount: - self.expected_revenue = self.amount * self.probability / 100 opportinity_for = "" if self.lead.lead_type == "customer": self.customer = self.lead.customer diff --git a/inventory/views.py b/inventory/views.py index 630f1c64..ec3759f3 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -6769,12 +6769,26 @@ def delete_note(request, dealer_slug, pk): :return: An HTTP redirection to the lead detail page of the corresponding note's lead. :rtype: HttpResponseRedirect """ - note = get_object_or_404(models.Notes, pk=pk, created_by=request.user) - lead_pk = note.content_object.pk - lead = models.Lead.objects.get(pk=lead_pk) - note.delete() - messages.success(request, _("Note deleted successfully.")) - return redirect("lead_detail", dealer_slug=dealer_slug, slug=lead.slug) + try: + note = get_object_or_404(models.Notes, pk=pk, created_by=request.user) + print(note) + if isinstance(note.content_object, models.Lead): + url = "lead_detail" + slug = note.content_object.slug + if hasattr(note.content_object, "opportunity"): + url = "opportunity_detail" + slug = note.content_object.opportunity.slug + elif isinstance(note.content_object, models.Opportunity): + url = "opportunity_detail" + slug = note.content_object.slug + + note.delete() + messages.success(request, _("Note deleted successfully.")) + except Exception as e: + print("Errroooorrr: ",e) + print(url) + print(dealer_slug) + return redirect(url, dealer_slug=dealer_slug,slug=slug) @login_required @@ -6856,9 +6870,9 @@ def schedule_event(request, dealer_slug, content_type, slug): dealer = get_object_or_404(models.Dealer, slug=dealer_slug) obj = get_object_or_404(model, slug=slug) - if not request.is_staff: - messages.error(request, _("You do not have permission to schedule.")) - return redirect(f"{content_type}_detail", dealer_slug=dealer_slug, slug=slug) + # if not request.is_staff: + # messages.error(request, _("You do not have permission to schedule.")) + # return redirect(f"{content_type}_detail", dealer_slug=dealer_slug, slug=slug) if request.method == "POST": from django_q.models import Schedule as DjangoQSchedule @@ -7359,7 +7373,6 @@ class OpportunityDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailV form.fields["stage"].widget.attrs["hx-get"] = url form.fields["stage"].initial = self.object.stage context["status_form"] = form - context["lead_notes"] = models.Notes.objects.filter( content_type__model="lead", object_id=self.object.id ).order_by("-created") @@ -10207,8 +10220,9 @@ def add_note(request, dealer_slug, content_type, slug): @require_http_methods(["POST"]) @permission_required("inventory.change_notes", raise_exception=True) def update_note(request, dealer_slug, pk): + print(pk) note = get_object_or_404(models.Notes, pk=pk) - lead = get_object_or_404(models.Lead, pk=note.content_object.id) + # lead = get_object_or_404(models.Lead, pk=note.content_object.id) dealer = get_object_or_404(models.Dealer, slug=dealer_slug) if request.method == "POST": note.note = request.POST.get("note") diff --git a/static/images/car_images/8fcc0cc6fc7c7e47a6be907d28965a75a0c3ea920e2e08c702acd88b5af2e433.png b/static/images/car_images/8fcc0cc6fc7c7e47a6be907d28965a75a0c3ea920e2e08c702acd88b5af2e433.png new file mode 100644 index 00000000..cbc48198 Binary files /dev/null and b/static/images/car_images/8fcc0cc6fc7c7e47a6be907d28965a75a0c3ea920e2e08c702acd88b5af2e433.png differ diff --git a/templates/account/logout.html b/templates/account/logout.html index 133adebe..c3e29a7b 100644 --- a/templates/account/logout.html +++ b/templates/account/logout.html @@ -13,7 +13,7 @@

{{ _("Are you sure you want to sign out?") }}

-
+ {% csrf_token %} {{ redirect_field }}
diff --git a/templates/account/password_change.html b/templates/account/password_change.html index 092441b4..36546bb3 100644 --- a/templates/account/password_change.html +++ b/templates/account/password_change.html @@ -27,7 +27,7 @@

{% trans "Change Password" %}

diff --git a/templates/account/signup-wizard.html b/templates/account/signup-wizard.html index dbff7727..f1ce90f1 100644 --- a/templates/account/signup-wizard.html +++ b/templates/account/signup-wizard.html @@ -24,7 +24,8 @@

{% trans 'Car Dealership Registration' %}

{% trans 'Create your dealership account today' %}

- +
+
{% csrf_token %}
diff --git a/templates/base.html b/templates/base.html index 7c8b42c8..c9c5376f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -87,13 +87,7 @@
+ class="fade-me-in"> {% block customCSS %}{% endblock %} {% block content %} {% endblock content %} diff --git a/templates/bill/includes/card_bill.html b/templates/bill/includes/card_bill.html index 13865c1e..99ac835d 100644 --- a/templates/bill/includes/card_bill.html +++ b/templates/bill/includes/card_bill.html @@ -1,6 +1,6 @@ {% load django_ledger %} {% load i18n %} -
+
{% if not create_bill %} {% if style == 'dashboard' %} @@ -54,7 +54,7 @@ {% trans 'View' %} {% if perms.django_ledger.change_billmodel %} - {% trans 'Update' %} {% if bill.can_pay %} @@ -203,7 +203,7 @@ {% if perms.django_ledger.change_billmodel %} {% if "update" not in request.path %} -
{% endblock %} diff --git a/templates/inventory/car_form.html b/templates/inventory/car_form.html index 7de7dfa9..26b503cf 100644 --- a/templates/inventory/car_form.html +++ b/templates/inventory/car_form.html @@ -25,7 +25,7 @@ {% endif %}
+ >
diff --git a/templates/ledger/bills/bill_form.html b/templates/ledger/bills/bill_form.html index 4392d209..a581d4c8 100644 --- a/templates/ledger/bills/bill_form.html +++ b/templates/ledger/bills/bill_form.html @@ -5,7 +5,7 @@ {{ _("Create Bill") }} {% endblock title %} {% block content %} -
+

{% trans "Create Bill" %}

diff --git a/templates/modal/delete_modal.html b/templates/modal/delete_modal.html index 95ec6e72..b4e27d2d 100644 --- a/templates/modal/delete_modal.html +++ b/templates/modal/delete_modal.html @@ -24,8 +24,10 @@
-
+
{% if estimate.status == 'draft' %} {% if perms.django_ledger.change_estimatemodel %}
{% else %} - {% include "empty-illustration-page.html" with value="sale order" url='#' %} + {% url 'estimate_create' request.dealer.slug as url %} + {% include "empty-illustration-page.html" with value="Sale Orders" url=url %} {% endif %} {% endblock %}