update
This commit is contained in:
parent
e551064560
commit
8556078b59
18
inventory/migrations/0002_alter_notes_object_id.py
Normal file
18
inventory/migrations/0002_alter_notes_object_id.py
Normal 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(),
|
||||
),
|
||||
]
|
||||
18
inventory/migrations/0003_alter_email_object_id.py
Normal file
18
inventory/migrations/0003_alter_email_object_id.py
Normal 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(),
|
||||
),
|
||||
]
|
||||
@ -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(),
|
||||
),
|
||||
]
|
||||
@ -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(),
|
||||
),
|
||||
]
|
||||
@ -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(),
|
||||
),
|
||||
]
|
||||
@ -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)
|
||||
|
||||
@ -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():
|
||||
|
||||
@ -87,19 +87,17 @@
|
||||
</a>
|
||||
</div>
|
||||
<table class="table fs-9 mb-0 table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="align-middle pe-6 text-start" scope="col">
|
||||
{{ _("Notes")|upper }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list">
|
||||
{% for note in notes %}
|
||||
<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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% for note in notes %}
|
||||
|
||||
<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-body-tertiary text-start white-space-nowrap">{{ note.created }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user