Feature: общая сумма заказа и автор только для отображения в формах заказов
Made-with: Cursor
This commit is contained in:
@@ -32,9 +32,11 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def set_author(form, request):
|
||||
"""Подставить автора из профиля пользователя."""
|
||||
"""Подставить автора из профиля пользователя при создании документа."""
|
||||
if form.instance.pk:
|
||||
return # при редактировании автора не меняем
|
||||
author = get_author_employee(request.user)
|
||||
if author and "author" in form.fields:
|
||||
if author:
|
||||
form.instance.author = author
|
||||
|
||||
|
||||
@@ -54,6 +56,7 @@ class CustomerOrderCreate(LoginRequiredMixin, CreateView):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["formset"] = CustomerOrderItemFormSet(instance=self.object) if self.object and self.object.pk else CustomerOrderItemFormSet()
|
||||
ctx["title"] = "Заказ клиента"
|
||||
ctx["author_display"] = get_author_employee(self.request.user) if not self.object or not self.object.pk else self.object.author
|
||||
return ctx
|
||||
|
||||
def form_valid(self, form):
|
||||
@@ -85,6 +88,7 @@ class CustomerOrderUpdate(LoginRequiredMixin, UpdateView):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["formset"] = CustomerOrderItemFormSetUpdate(instance=self.object)
|
||||
ctx["title"] = "Заказ клиента"
|
||||
ctx["author_display"] = self.object.author
|
||||
return ctx
|
||||
|
||||
def form_valid(self, form):
|
||||
@@ -134,6 +138,7 @@ class SupplierOrderCreate(LoginRequiredMixin, CreateView):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["formset"] = SupplierOrderItemFormSet(instance=self.object) if self.object and self.object.pk else SupplierOrderItemFormSet()
|
||||
ctx["title"] = "Заказ поставщику"
|
||||
ctx["author_display"] = get_author_employee(self.request.user) if not self.object or not self.object.pk else self.object.author
|
||||
return ctx
|
||||
|
||||
def form_valid(self, form):
|
||||
@@ -165,6 +170,7 @@ class SupplierOrderUpdate(LoginRequiredMixin, UpdateView):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["formset"] = SupplierOrderItemFormSetUpdate(instance=self.object)
|
||||
ctx["title"] = "Заказ поставщику"
|
||||
ctx["author_display"] = self.object.author
|
||||
return ctx
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
Reference in New Issue
Block a user