add party model
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
from .order import *
|
from .order import *
|
||||||
from .offer import *
|
from .offer import *
|
||||||
|
from .party import *
|
||||||
9
core/apps/orders/admin/party.py
Normal file
9
core/apps/orders/admin/party.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from core.apps.orders.models import Party
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Party)
|
||||||
|
class PartyAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['mediator', 'delivery_date', 'payment_date']
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-21 10:14
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('counterparty', '0001_initial'),
|
||||||
|
('orders', '0008_remove_offer_name_offer_counterparty'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='counterparty',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='order', to='counterparty.counterparty'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='currency',
|
||||||
|
field=models.CharField(blank=True, choices=[('uzs', 'uzs'), ('usd', 'usd')], default='uzs', max_length=3, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='total_price',
|
||||||
|
field=models.PositiveBigIntegerField(blank=True, default=0, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='unit_amount',
|
||||||
|
field=models.PositiveBigIntegerField(blank=True, default=0, null=True),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Party',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('delivery_date', models.DateField()),
|
||||||
|
('payment_date', models.DateField()),
|
||||||
|
('comment', models.TextField(blank=True, null=True)),
|
||||||
|
('audit', models.CharField(blank=True, choices=[('CHECKED', 'tekshirildi'), ('PROCESS', 'jarayonda')], max_length=20, null=True)),
|
||||||
|
('audit_comment', models.TextField(blank=True, null=True)),
|
||||||
|
('mediator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parties', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('orders', models.ManyToManyField(blank=True, null=True, related_name='parties', to='orders.order')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Partiya',
|
||||||
|
'verbose_name_plural': 'Partiyalar',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
from .order import *
|
from .order import *
|
||||||
from .order_offer import *
|
from .order_offer import *
|
||||||
|
from .party import *
|
||||||
@@ -6,6 +6,7 @@ from core.apps.products.models import Product, Unity
|
|||||||
from core.apps.projects.models import Project, ProjectFolder
|
from core.apps.projects.models import Project, ProjectFolder
|
||||||
from core.apps.accounts.models import User
|
from core.apps.accounts.models import User
|
||||||
from core.apps.wherehouse.models import WhereHouse
|
from core.apps.wherehouse.models import WhereHouse
|
||||||
|
from core.apps.counterparty.models import Counterparty
|
||||||
|
|
||||||
|
|
||||||
class Order(BaseModel):
|
class Order(BaseModel):
|
||||||
@@ -34,6 +35,14 @@ class Order(BaseModel):
|
|||||||
quantity = models.PositiveBigIntegerField(default=1)
|
quantity = models.PositiveBigIntegerField(default=1)
|
||||||
status = models.CharField(max_length=20, choices=STATUS, default="NEW")
|
status = models.CharField(max_length=20, choices=STATUS, default="NEW")
|
||||||
employee = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders', null=True)
|
employee = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders', null=True)
|
||||||
|
unit_amount = models.PositiveBigIntegerField(default=0, null=True, blank=True)
|
||||||
|
counterparty = models.ForeignKey(
|
||||||
|
Counterparty, on_delete=models.SET_NULL, null=True, blank=True, related_name='order'
|
||||||
|
)
|
||||||
|
currency = models.CharField(
|
||||||
|
choices=[('uzs', 'uzs'), ('usd', 'usd')], default='uzs', null=True, blank=True, max_length=3
|
||||||
|
)
|
||||||
|
total_price = models.PositiveBigIntegerField(default=0, null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.product} {self.unity} quantity order"
|
return f"{self.product} {self.unity} quantity order"
|
||||||
|
|||||||
25
core/apps/orders/models/party.py
Normal file
25
core/apps/orders/models/party.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from core.apps.shared.models import BaseModel
|
||||||
|
from core.apps.orders.models.order import Order
|
||||||
|
from core.apps.accounts.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class Party(BaseModel):
|
||||||
|
orders = models.ManyToManyField(Order, related_name='parties', null=True, blank=True)
|
||||||
|
mediator = models.ForeignKey(User, on_delete=models.CASCADE, related_name='parties')
|
||||||
|
delivery_date = models.DateField()
|
||||||
|
payment_date = models.DateField()
|
||||||
|
comment = models.TextField(null=True, blank=True)
|
||||||
|
audit = models.CharField(
|
||||||
|
max_length=20, choices=[('CHECKED', 'tekshirildi'),('PROCESS', 'jarayonda')],
|
||||||
|
null=True, blank=True
|
||||||
|
)
|
||||||
|
audit_comment = models.TextField(null=True, blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.mediator.full_name} {self.delivery_date}'
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Partiya'
|
||||||
|
verbose_name_plural = 'Partiyalar'
|
||||||
Reference in New Issue
Block a user