fix(inventory, orders, pos): удалена зависимость от django-simple-history для tenant-моделей

- Добавлен pre_save сигнал для Order вместо django-simple-history
- Переписаны все функции signals.py без использования instance.history
- Заменены .username на .name|default:.email для CustomUser в шаблонах
- Исправлен CSRF-токен в POS для работы с CSRF_USE_SESSIONS=True

Теперь создание заказов работает корректно в мультитенантной архитектуре.
This commit is contained in:
2026-01-10 17:21:00 +03:00
parent 8f3c90c11a
commit 4ea01b8269
12 changed files with 85 additions and 118 deletions

View File

@@ -688,10 +688,10 @@
<td><span class="badge bg-info">{{ doc.get_receipt_type_display }}</span></td>
<td class="text-muted-small">{{ doc.date|date:"d.m.Y" }}</td>
<td>{{ doc.supplier_name|default:"-" }}</td>
<td class="text-muted-small">{{ doc.created_by.username|default:"-" }}</td>
<td class="text-muted-small">{{ doc.created_by.name|default:doc.created_by.email|default:"-" }}</td>
<td class="text-muted-small">
{% if doc.confirmed_by %}
{{ doc.confirmed_by.username }} ({{ doc.confirmed_at|date:"d.m H:i" }})
{{ doc.confirmed_by.name|default:doc.confirmed_by.email }} ({{ doc.confirmed_at|date:"d.m H:i" }})
{% else %}
-
{% endif %}

View File

@@ -17,16 +17,6 @@
</ol>
</nav>
<!-- Messages -->
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
{% endfor %}
{% endif %}
<div class="row g-3">
<!-- Основной контент - одна колонка -->
<div class="col-12">
@@ -102,7 +92,7 @@
</div>
<div class="col-md-6">
<p class="text-muted small mb-1">Провёл</p>
<p class="fw-semibold">{% if document.confirmed_by %}{{ document.confirmed_by.username }}{% else %}-{% endif %}</p>
<p class="fw-semibold">{% if document.confirmed_by %}{{ document.confirmed_by.name|default:document.confirmed_by.email }}{% else %}-{% endif %}</p>
</div>
</div>
{% endif %}

View File

@@ -67,7 +67,7 @@
<td class="px-3 py-2 text-end">{{ doc.items.count }}</td>
<td class="px-3 py-2 text-end">{{ doc.total_quantity }}</td>
<td class="px-3 py-2">
{% if doc.created_by %}{{ doc.created_by.username }}{% else %}-{% endif %}
{% if doc.created_by %}{{ doc.created_by.name|default:doc.created_by.email }}{% else %}-{% endif %}
</td>
<td class="px-3 py-2 text-end">
<a href="{% url 'inventory:incoming-detail' doc.pk %}" class="btn btn-sm btn-outline-primary">

View File

@@ -85,7 +85,7 @@
</div>
<div class="col-md-3">
<p class="text-muted small mb-1">Сотрудник</p>
<p class="fw-semibold">{% if transformation.employee %}{{ transformation.employee.username }}{% else %}-{% endif %}</p>
<p class="fw-semibold">{% if transformation.employee %}{{ transformation.employee.name|default:transformation.employee.email }}{% else %}-{% endif %}</p>
</div>
</div>

View File

@@ -75,7 +75,7 @@
{% endfor %}
</td>
<td class="px-3 py-2">
{% if transformation.employee %}{{ transformation.employee.username }}{% else %}-{% endif %}
{% if transformation.employee %}{{ transformation.employee.name|default:transformation.employee.email }}{% else %}-{% endif %}
</td>
<td class="px-3 py-2 text-end">
<a href="{% url 'inventory:transformation-detail' transformation.pk %}" class="btn btn-sm btn-outline-primary">

View File

@@ -91,7 +91,7 @@
</div>
<div class="col-md-6">
<p class="text-muted small mb-1">Провёл</p>
<p class="fw-semibold">{% if document.confirmed_by %}{{ document.confirmed_by.username }}{% else %}-{% endif %}</p>
<p class="fw-semibold">{% if document.confirmed_by %}{{ document.confirmed_by.name|default:document.confirmed_by.email }}{% else %}-{% endif %}</p>
</div>
</div>
{% endif %}

View File

@@ -63,7 +63,7 @@
<td class="px-3 py-2 text-end">{{ doc.items.count }}</td>
<td class="px-3 py-2 text-end">{{ doc.total_quantity }}</td>
<td class="px-3 py-2">
{% if doc.created_by %}{{ doc.created_by.username }}{% else %}-{% endif %}
{% if doc.created_by %}{{ doc.created_by.name|default:doc.created_by.email }}{% else %}-{% endif %}
</td>
<td class="px-3 py-2 text-end">
<a href="{% url 'inventory:writeoff-document-detail' doc.pk %}" class="btn btn-sm btn-outline-primary">