add: add new field to Inventory model
This commit is contained in:
@@ -4,13 +4,14 @@ from core.apps.wherehouse.models.inventory import Inventory
|
|||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def create_inventory(wherehouse, quantity, product, unity, price, project_folder, project):
|
def create_inventory(wherehouse, quantity, product, unity, price, project_folder, project, unity_price):
|
||||||
Inventory.objects.create(
|
Inventory.objects.create(
|
||||||
wherehouse_id=wherehouse,
|
wherehouse_id=wherehouse,
|
||||||
quantity=quantity,
|
quantity=quantity,
|
||||||
product_id=product,
|
product_id=product,
|
||||||
unity_id=unity,
|
unity_id=unity,
|
||||||
price=price,
|
price=price,
|
||||||
project_folder_id=project_folder,
|
project_folder_id=project_folder,
|
||||||
project_id=project,
|
project_id=project,
|
||||||
)
|
unit_price=unity_price
|
||||||
|
)
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ class PartyChangeStatusToIsMadeApiView(generics.GenericAPIView):
|
|||||||
order.unit_amount * order.quantity,
|
order.unit_amount * order.quantity,
|
||||||
order.project_folder.id if order.project_folder else None,
|
order.project_folder.id if order.project_folder else None,
|
||||||
order.project.id if order.project else None,
|
order.project.id if order.project else None,
|
||||||
|
order.unit_amount,
|
||||||
)
|
)
|
||||||
return Response(
|
return Response(
|
||||||
{'success': True, 'message': 'party updated'},
|
{'success': True, 'message': 'party updated'},
|
||||||
|
|||||||
18
core/apps/wherehouse/migrations/0007_inventory_unit_price.py
Normal file
18
core/apps/wherehouse/migrations/0007_inventory_unit_price.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-27 10:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wherehouse', '0006_inventory_is_invalid'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventory',
|
||||||
|
name='unit_price',
|
||||||
|
field=models.PositiveBigIntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -27,6 +27,7 @@ class Inventory(BaseModel):
|
|||||||
related_name='inventories'
|
related_name='inventories'
|
||||||
)
|
)
|
||||||
is_invalid = models.BooleanField(default=False)
|
is_invalid = models.BooleanField(default=False)
|
||||||
|
unit_price = models.PositiveBigIntegerField(default=0)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.product} in {self.wherehouse}'
|
return f'{self.product} in {self.wherehouse}'
|
||||||
|
|||||||
Reference in New Issue
Block a user