update
This commit is contained in:
parent
286031b4d8
commit
93b829fd51
@ -1273,6 +1273,17 @@ class OpportunityForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
print(kwargs)
|
||||
dealer = kwargs.pop('dealer', None)
|
||||
print(dealer)
|
||||
|
||||
# Apply filtering if a dealer is provided
|
||||
if dealer:
|
||||
# Assuming Car model has an 'entity' ForeignKey and Dealer has an 'entity' attribute
|
||||
self.fields['car'].queryset = Car.objects.filter(entity=dealer.entity)
|
||||
|
||||
# Assuming Lead model has an 'entity' ForeignKey and Dealer has an 'entity' attribute
|
||||
self.fields['lead'].queryset = Lead.objects.filter(entity=dealer.entity)
|
||||
# Add a visible number input to display the current value
|
||||
self.fields["probability"].widget.attrs["class"] = (
|
||||
"d-none" # Hide the default input
|
||||
|
||||
@ -8,7 +8,6 @@ import logging
|
||||
import tempfile
|
||||
import numpy as np
|
||||
from time import sleep
|
||||
|
||||
# from rich import print
|
||||
from random import randint
|
||||
from decimal import Decimal
|
||||
@ -9324,6 +9323,74 @@ class PurchaseOrderListView(LoginRequiredMixin, PermissionRequiredMixin, ListVie
|
||||
dealer = get_user_type(self.request)
|
||||
entity = dealer.entity
|
||||
return self.model.objects.filter(entity=entity)
|
||||
|
||||
def get_queryset(self):
|
||||
dealer = get_user_type(self.request)
|
||||
entity = dealer.entity
|
||||
queryset = self.model.objects.filter(entity=entity)
|
||||
|
||||
query = self.request.GET.get('q') # This is generic: looks for 'q' from GET
|
||||
|
||||
if query:
|
||||
# Start with an empty Q object for the search filters
|
||||
search_filters = Q()
|
||||
|
||||
# 1. Try to parse the query as a date
|
||||
parsed_date = None
|
||||
date_formats = [
|
||||
'%Y-%m-%d', # 2023-10-26
|
||||
'%m/%d/%Y', # 10/26/2023
|
||||
'%d-%m-%Y', # 26-10-2023
|
||||
'%B %d, %Y', # October 26, 2023
|
||||
'%b %d, %Y', # Oct 26, 2023
|
||||
'%Y/%m/%d', # 2023/10/26
|
||||
'%Y-%m', # 2023-10 (for year-month search)
|
||||
'%Y',
|
||||
'%b %d',
|
||||
'%B %d' # 2023 (for year search)
|
||||
]
|
||||
|
||||
for fmt in date_formats:
|
||||
try:
|
||||
# For '%Y-%m' and '%Y', we only care about year/month, not exact day
|
||||
if fmt == '%Y-%m':
|
||||
parsed_date = datetime.strptime(query, fmt)
|
||||
search_filters |= Q(created__year=parsed_date.year, created__month=parsed_date.month)
|
||||
break
|
||||
elif fmt == '%Y':
|
||||
parsed_date = datetime.strptime(query, fmt)
|
||||
search_filters |= Q(created__year=parsed_date.year)
|
||||
break
|
||||
else:
|
||||
parsed_date = datetime.strptime(query, fmt).date()
|
||||
search_filters |= Q(created__date=parsed_date) # Matches exact date part of datetime field
|
||||
break # Found a match, no need to try other formats
|
||||
except ValueError:
|
||||
continue # Try next format
|
||||
|
||||
# 2. Add text-based search filters (always apply these)
|
||||
# Combine them with OR operator
|
||||
text_filters = (
|
||||
Q(po_number__icontains=query) |
|
||||
Q(po_title__icontains=query) |
|
||||
Q(po_status__icontains=query) |
|
||||
Q(created__icontains=query)
|
||||
|
||||
)
|
||||
|
||||
# If a date was successfully parsed, combine with text filters
|
||||
if parsed_date:
|
||||
# Use a combined Q object. This means it will search for
|
||||
# (date_match OR po_number_match OR po_title_match)
|
||||
queryset = queryset.filter(search_filters | text_filters).distinct()
|
||||
else:
|
||||
# If no date was parsed, only apply text filters
|
||||
queryset = queryset.filter(text_filters).distinct()
|
||||
|
||||
return queryset
|
||||
|
||||
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
dealer = get_user_type(self.request)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 964 KiB |
@ -3,7 +3,7 @@
|
||||
{% block title %}{{ _('Leads')|capfirst }}{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row g-3 mt-4">
|
||||
<div class="row g-3 mt-4 mb-4">
|
||||
<h2 class="mb-2">{{ _("Leads")|capfirst }}</h2>
|
||||
<!-- Action Tracking Modal -->
|
||||
{% include "crm/leads/partials/update_action.html" %}
|
||||
|
||||
@ -87,7 +87,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="opportunities-grid" class="row g-4 px-2 px-lg-4 mt-1">
|
||||
<div id="opportunities-grid" class="row g-4 px-2 px-lg-4 mt-1 mb-4">
|
||||
{% include 'crm/opportunities/partials/opportunity_grid.html' %}
|
||||
</div>
|
||||
{% if page_obj.paginator.num_pages > 1 %}
|
||||
|
||||
@ -120,10 +120,10 @@
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<a class="btn btn-sm btn-phoenix-primary" href="{% url 'opportunity_detail' request.dealer.slug opportunity.slug %}">
|
||||
{{ _("View Details") }} <i class="fa-solid fa-eye ms-2"></i>
|
||||
<i class="fa-solid fa-eye ms-2"></i>{{ _("View") }}
|
||||
</a>
|
||||
<a class="btn btn-sm btn-phoenix-success" href="{% url 'update_opportunity' request.dealer.slug opportunity.slug %}">
|
||||
{{ _("Update") }} <i class="fa-solid fa-pen ms-2"></i>
|
||||
<i class="fa-solid fa-pen ms-2"></i> {{ _("Update") }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -109,11 +109,7 @@
|
||||
{{ _("Delete") }}
|
||||
</a>
|
||||
<a class="btn btn-sm btn-phoenix-secondary"
|
||||
<<<<<<< HEAD
|
||||
href="{% url 'group_list' request.dealer.slug%}">
|
||||
=======
|
||||
href="{% url 'group_list' request.dealer.slug %}">
|
||||
>>>>>>> c9fad7b79c346875a636122fdc7514814180dbc7
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
{% trans "Back to List" %}
|
||||
</a>
|
||||
|
||||
@ -32,11 +32,12 @@
|
||||
<div class="text-danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
<div class="d-flex mb-3">
|
||||
<a href="{% url 'group_detail' request.dealer.slug group.pk %}" class="btn btn-phoenix-primary me-2 "><i class="fa-solid fa-ban"></i> {% trans "Cancel"|capfirst %}</a>
|
||||
<button class="btn btn-phoenix-primary" type="submit">
|
||||
<button class="btn btn-phoenix-primary me-2" type="submit">
|
||||
<i class="fa-solid fa-floppy-disk"></i>
|
||||
{{ _("Save") }}
|
||||
</button>
|
||||
<a href="{% url 'group_detail' request.dealer.slug group.pk %}" class="btn btn-phoenix-secondary "><i class="fa-solid fa-ban"></i> {% trans "Cancel"|capfirst %}</a>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -11,14 +11,13 @@
|
||||
<li class="list-group-item"><strong>{% trans "Address" %}:</strong> {{ organization.address }}</li>
|
||||
</ul>
|
||||
<div class="d-flex">
|
||||
<a href="{% url 'organization_update' organization.pk %}" class="btn btn-sm btn-phoenix-warning me-2">{% trans "Edit" %}</a>
|
||||
<a href="{% url 'organization_update' request.dealer.slug organization.slug %}" class="btn btn-sm btn-phoenix-primary me-2"><span class="fas fa-edit me-1"></span>{% trans "Edit" %}</a>
|
||||
<button class="btn btn-phoenix-danger btn-sm delete-btn"
|
||||
data-url="{% url 'organization_delete' organization.slug %}"
|
||||
data-url="{% url 'organization_delete' request.dealer.slug organization.slug %}"
|
||||
data-message="Are you sure you want to delete this organization?"
|
||||
data-bs-toggle="modal" data-bs-target="#deleteModal">
|
||||
{% trans 'Delete' %}<i class="fas fa-trash ms-1"></i>
|
||||
<i class="fas fa-trash me-1"></i> {% trans 'Delete' %}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% include 'modal/delete_modal.html' %}
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="container-fluid mt-4">
|
||||
<!--Heading-->
|
||||
<h3>
|
||||
<h3 class="mb-3">
|
||||
{% if object %}
|
||||
{% trans 'Update Organization'%}
|
||||
{% else %}
|
||||
|
||||
@ -65,9 +65,9 @@
|
||||
<div class="btn-reveal-trigger position-static">
|
||||
<button class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true" aria-expanded="false" data-bs-reference="parent"><span class="fas fa-ellipsis-h fs-10"></span></button>
|
||||
<div class="dropdown-menu dropdown-menu-end py-2">
|
||||
<a href="{% url 'purchase_order_detail' request.dealer.slug po.pk %}" class="dropdown-item text-success-dark">{% trans 'Detail' %}</a>
|
||||
<a href="{% url 'purchase_order_detail' request.dealer.slug po.pk %}" class="dropdown-item text-success-dark">{% trans 'Purchase Order Detail' %}</a>
|
||||
{% if po.po_status == 'fulfilled' %}
|
||||
<a href="{% url 'view_items_inventory' dealer_slug=request.dealer.slug entity_slug=entity_slug po_pk=po.pk %}" class="dropdown-item text-success-dark">{% trans 'View Inventory Items' %}</a>
|
||||
<a href="{% url 'view_items_inventory' dealer_slug=request.dealer.slug entity_slug=entity_slug po_pk=po.pk %}" class="dropdown-item text-success-dark">{% trans 'Add Inventory Items' %}</a>
|
||||
{% else %}
|
||||
<button class="dropdown-item text-warning-dark" disabled><span class="fas fa-exclamation-triangle me-1"></span> Fulfill the PO Before Viewing Inventory</button>
|
||||
{% endif %}
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="row justify-content-center mb-4">
|
||||
<div class="col-lg-10">
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-primary text-white">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user