This commit is contained in:
Marwan Alwali 2025-04-28 13:27:08 +03:00
parent e551064560
commit 8556078b59
8 changed files with 120 additions and 13 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 5.1.7 on 2025-04-24 16:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='notes',
name='object_id',
field=models.PositiveBigIntegerField(),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 5.1.7 on 2025-04-24 16:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0002_alter_notes_object_id'),
]
operations = [
migrations.AlterField(
model_name='email',
name='object_id',
field=models.PositiveBigIntegerField(),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.7 on 2025-04-24 16:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0003_alter_email_object_id'),
]
operations = [
migrations.AlterField(
model_name='email',
name='object_id',
field=models.UUIDField(),
),
migrations.AlterField(
model_name='notes',
name='object_id',
field=models.UUIDField(),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.7 on 2025-04-24 16:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0004_alter_email_object_id_alter_notes_object_id'),
]
operations = [
migrations.AlterField(
model_name='email',
name='object_id',
field=models.PositiveIntegerField(),
),
migrations.AlterField(
model_name='notes',
name='object_id',
field=models.PositiveIntegerField(),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.7 on 2025-04-24 17:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0005_alter_email_object_id_alter_notes_object_id'),
]
operations = [
migrations.AlterField(
model_name='email',
name='object_id',
field=models.UUIDField(),
),
migrations.AlterField(
model_name='notes',
name='object_id',
field=models.UUIDField(),
),
]

View File

@ -1467,7 +1467,7 @@ class Opportunity(models.Model):
class Notes(models.Model): class Notes(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField() object_id = models.UUIDField()
content_object = GenericForeignKey("content_type", "object_id") content_object = GenericForeignKey("content_type", "object_id")
note = models.TextField(verbose_name=_("Note")) note = models.TextField(verbose_name=_("Note"))
created_by = models.ForeignKey( created_by = models.ForeignKey(
@ -1485,7 +1485,7 @@ class Notes(models.Model):
class Email(models.Model): class Email(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField() object_id = models.UUIDField()
content_object = GenericForeignKey("content_type", "object_id") content_object = GenericForeignKey("content_type", "object_id")
from_email = models.TextField(verbose_name=_("From Email"),null=True,blank=True) from_email = models.TextField(verbose_name=_("From Email"),null=True,blank=True)
to_email = models.TextField(verbose_name=_("To Email"),null=True,blank=True) to_email = models.TextField(verbose_name=_("To Email"),null=True,blank=True)

View File

@ -1915,11 +1915,15 @@ class CustomerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
dealer = get_user_type(self.request) dealer = get_user_type(self.request)
entity = dealer.entity entity = dealer.entity
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["customer_notes"] = models.Notes.objects.filter(
object_id=self.object.pk
)
estimates = entity.get_estimates().filter(customer=self.object) estimates = entity.get_estimates().filter(customer=self.object)
invoices = entity.get_invoices().filter(customer=self.object) invoices = entity.get_invoices().filter(customer=self.object)
# txs = entity. transactions(customer=self.object) # txs = entity. transactions(customer=self.object)
total = estimates.count() + invoices.count() total = estimates.count() + invoices.count()
context["estimates"] = estimates context["estimates"] = estimates
context["invoices"] = invoices context["invoices"] = invoices
context["total"] = total context["total"] = total
@ -1927,7 +1931,7 @@ class CustomerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
@login_required @login_required
def add_note_to_customer(request, customer_id): def add_note_to_customer(request, pk):
""" """
This function allows authenticated users to add a note to a specific customer. The This function allows authenticated users to add a note to a specific customer. The
note creation is handled by a form, which is validated after submission. If the form note creation is handled by a form, which is validated after submission. If the form
@ -1944,7 +1948,7 @@ def add_note_to_customer(request, customer_id):
POST request, it renders the note form template with context including POST request, it renders the note form template with context including
the form and customer. the form and customer.
""" """
customer = get_object_or_404(CustomerModel, uuid=customer_id) customer = get_object_or_404(CustomerModel, pk=pk)
if request.method == "POST": if request.method == "POST":
form = forms.NoteForm(request.POST) form = forms.NoteForm(request.POST)
if form.is_valid(): if form.is_valid():

View File

@ -87,19 +87,17 @@
</a> </a>
</div> </div>
<table class="table fs-9 mb-0 table-responsive"> <table class="table fs-9 mb-0 table-responsive">
<thead>
<tr> <tr>
<th class="align-middle pe-6 text-start" scope="col"> <th class="align-middle pe-6 text-start" scope="col">
{{ _("Notes")|upper }}</th> {{ _("Notes")|upper }}</th>
</tr> </tr>
</thead> {% for note in notes %}
<tbody class="list">
{% for note in notes %} <tr class="hover-actions-trigger btn-reveal-trigger position-static">
<tr class="hover-actions-trigger btn-reveal-trigger position-static"> <td class="align-middle text-start fw-bold text-body-tertiary ps-1">{{note.note}}</td>
<td class="align-middle text-start fw-bold text-body-tertiary ps-1">{{note.note}}</td> <td class="align-middle text-body-tertiary text-start white-space-nowrap">{{ note.created }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody>
</table> </table>
</div> </div>
</div> </div>