diff --git a/inventory/migrations/0002_alter_notes_object_id.py b/inventory/migrations/0002_alter_notes_object_id.py new file mode 100644 index 00000000..25b4e530 --- /dev/null +++ b/inventory/migrations/0002_alter_notes_object_id.py @@ -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(), + ), + ] diff --git a/inventory/migrations/0003_alter_email_object_id.py b/inventory/migrations/0003_alter_email_object_id.py new file mode 100644 index 00000000..a2d528d2 --- /dev/null +++ b/inventory/migrations/0003_alter_email_object_id.py @@ -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(), + ), + ] diff --git a/inventory/migrations/0004_alter_email_object_id_alter_notes_object_id.py b/inventory/migrations/0004_alter_email_object_id_alter_notes_object_id.py new file mode 100644 index 00000000..da3b3751 --- /dev/null +++ b/inventory/migrations/0004_alter_email_object_id_alter_notes_object_id.py @@ -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(), + ), + ] diff --git a/inventory/migrations/0005_alter_email_object_id_alter_notes_object_id.py b/inventory/migrations/0005_alter_email_object_id_alter_notes_object_id.py new file mode 100644 index 00000000..e74ab873 --- /dev/null +++ b/inventory/migrations/0005_alter_email_object_id_alter_notes_object_id.py @@ -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(), + ), + ] diff --git a/inventory/migrations/0006_alter_email_object_id_alter_notes_object_id.py b/inventory/migrations/0006_alter_email_object_id_alter_notes_object_id.py new file mode 100644 index 00000000..55c616ad --- /dev/null +++ b/inventory/migrations/0006_alter_email_object_id_alter_notes_object_id.py @@ -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(), + ), + ] diff --git a/inventory/models.py b/inventory/models.py index 71e0c161..af152bce 100644 --- a/inventory/models.py +++ b/inventory/models.py @@ -1467,7 +1467,7 @@ class Opportunity(models.Model): class Notes(models.Model): content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id = models.PositiveIntegerField() + object_id = models.UUIDField() content_object = GenericForeignKey("content_type", "object_id") note = models.TextField(verbose_name=_("Note")) created_by = models.ForeignKey( @@ -1485,7 +1485,7 @@ class Notes(models.Model): class Email(models.Model): content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id = models.PositiveIntegerField() + object_id = models.UUIDField() content_object = GenericForeignKey("content_type", "object_id") from_email = models.TextField(verbose_name=_("From Email"),null=True,blank=True) to_email = models.TextField(verbose_name=_("To Email"),null=True,blank=True) diff --git a/inventory/views.py b/inventory/views.py index 26a9203f..cb3c7679 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -1915,11 +1915,15 @@ class CustomerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView dealer = get_user_type(self.request) entity = dealer.entity 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) invoices = entity.get_invoices().filter(customer=self.object) # txs = entity. transactions(customer=self.object) total = estimates.count() + invoices.count() + context["estimates"] = estimates context["invoices"] = invoices context["total"] = total @@ -1927,7 +1931,7 @@ class CustomerDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView @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 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 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": form = forms.NoteForm(request.POST) if form.is_valid(): diff --git a/templates/customers/view_customer.html b/templates/customers/view_customer.html index 0d9b4ac3..f7bb21db 100644 --- a/templates/customers/view_customer.html +++ b/templates/customers/view_customer.html @@ -87,19 +87,17 @@ - - - - {% for note in notes %} - - - - {% endfor %} - + {% for note in notes %} + + + + + + {% endfor %}
{{ _("Notes")|upper }}
{{note.note}}
{{note.note}}{{ note.created }}