add notification and send notification
This commit is contained in:
@@ -16,6 +16,8 @@ from core.apps.projects.models import Project, ProjectFolder
|
||||
from core.apps.projects.serializers.project import ProjectListSerializer, ProjectFolderListSerializer
|
||||
# counterparty
|
||||
from core.apps.counterparty.models import Counterparty
|
||||
# notifications
|
||||
from core.apps.notifications.utils.notify_user import notify_user
|
||||
|
||||
|
||||
class OrderCreateSerializer(serializers.Serializer):
|
||||
@@ -71,7 +73,7 @@ class MultipleOrderCreateSerializer(serializers.Serializer):
|
||||
orders = []
|
||||
|
||||
for resource in resources:
|
||||
orders.append(Order(
|
||||
order = Order(
|
||||
product=resource['product'],
|
||||
unity=resource['unity'],
|
||||
wherehouse=resource['wherehouse'],
|
||||
@@ -80,8 +82,16 @@ class MultipleOrderCreateSerializer(serializers.Serializer):
|
||||
quantity=resource['quantity'],
|
||||
date=common_date,
|
||||
employee=self.context.get('user'),
|
||||
))
|
||||
)
|
||||
orders.append(order)
|
||||
body = f"""
|
||||
{user.full_name} {order.project_folder.name} uchun {order.wherehouse.name} ombor ga {order.quantity} {order.unity.value} {order.product.name} ga buyurtma berdi. Buyurtma
|
||||
yetkazish sanasi {common_date}
|
||||
"""
|
||||
notify_user(user=self.context.get("user"), title="Ta'minot",body=body)
|
||||
|
||||
created_orders = Order.objects.bulk_create(orders)
|
||||
user = self.context.get('user')
|
||||
return created_orders
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user