上传物流信息
This commit is contained in:
parent
cee38849dd
commit
e0b14846f0
|
@ -55,23 +55,18 @@ class InmService:
|
||||||
for i in FIFOItem.objects.filter(fifo=instance):
|
for i in FIFOItem.objects.filter(fifo=instance):
|
||||||
material = i.material
|
material = i.material
|
||||||
warehouse = i.warehouse
|
warehouse = i.warehouse
|
||||||
o1 = Inventory.objects.get(material=material, warehouse=warehouse)
|
mb = MaterialBatch.objects.get(material=material, warehouse=warehouse, batch=i.batch)
|
||||||
temp_count = o1.count - i.count
|
temp_count = mb.count - i.count
|
||||||
if temp_count < 0:
|
|
||||||
raise ValidationError('仓库库存不足,操作失败')
|
|
||||||
o1.count = temp_count
|
|
||||||
o1.save()
|
|
||||||
print(i.batch)
|
|
||||||
o2 = MaterialBatch.objects.get(material=material, warehouse=warehouse, batch=i.batch)
|
|
||||||
temp_count = o2.count - i.count
|
|
||||||
if temp_count < 0:
|
if temp_count < 0:
|
||||||
raise ValidationError('批次库存不足,操作失败')
|
raise ValidationError('批次库存不足,操作失败')
|
||||||
o2.count = temp_count
|
mb.count = temp_count
|
||||||
o2.save()
|
mb.save()
|
||||||
temp_count = material.count - i.count
|
|
||||||
if temp_count < 0:
|
iv = Inventory.objects.get(material=material, warehouse=warehouse)
|
||||||
raise ValidationError('物料库存不足,操作失败')
|
iv.count = MaterialBatch.objects.filter(material=material, warehouse=warehouse).count()
|
||||||
material.count = temp_count
|
iv.save()
|
||||||
|
|
||||||
|
material.count = MaterialBatch.objects.filter(material=material).count()
|
||||||
material.save()
|
material.save()
|
||||||
|
|
||||||
# 删除IProduct
|
# 删除IProduct
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.9 on 2022-02-25 01:10
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('sam', '0014_auto_20220222_1530'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sale',
|
||||||
|
name='ship_pic',
|
||||||
|
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='物流图片'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -93,6 +93,7 @@ class Sale(CommonADModel):
|
||||||
receiver_phone = models.CharField('收货人联系电话', null=True, blank=True, max_length=20)
|
receiver_phone = models.CharField('收货人联系电话', null=True, blank=True, max_length=20)
|
||||||
receiver_address = models.CharField('收获地址', null=True, blank=True, max_length=200)
|
receiver_address = models.CharField('收获地址', null=True, blank=True, max_length=200)
|
||||||
remark = models.CharField('备注', null=True, blank=True, max_length=200)
|
remark = models.CharField('备注', null=True, blank=True, max_length=200)
|
||||||
|
ship_pic = models.CharField('物流图片', max_length=200, null=True, blank=True)
|
||||||
|
|
||||||
class SaleProduct(BaseModel):
|
class SaleProduct(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -97,3 +97,6 @@ class SaleProductPackSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class SRemarkItemCreateSerializer(serializers.Serializer):
|
class SRemarkItemCreateSerializer(serializers.Serializer):
|
||||||
remark = serializers.CharField(min_length=6)
|
remark = serializers.CharField(min_length=6)
|
||||||
|
|
||||||
|
class SaleUpShipPicSerializer(serializers.Serializer):
|
||||||
|
path = serializers.CharField(min_length=200)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct, IProduct, WareHouse
|
||||||
from apps.inm.services import InmService
|
from apps.inm.services import InmService
|
||||||
from apps.mtm.models import Material, PackItem
|
from apps.mtm.models import Material, PackItem
|
||||||
from apps.sam.models import Sale, SalePack, SaleProduct
|
from apps.sam.models import Sale, SalePack, SaleProduct
|
||||||
from apps.sam.serializers_sale import SRemarkItemCreateSerializer, SaleCreateSerializer, SaleListSerializer, SaleProductCreateSerializer, SaleProductListSerializer, SaleProductPackDetailSerializer, SaleProductPackSerializer
|
from apps.sam.serializers_sale import SRemarkItemCreateSerializer, SaleCreateSerializer, SaleListSerializer, SaleProductCreateSerializer, SaleProductListSerializer, SaleProductPackDetailSerializer, SaleProductPackSerializer, SaleUpShipPicSerializer
|
||||||
from rest_framework import exceptions
|
from rest_framework import exceptions
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
|
@ -85,8 +85,6 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
|
||||||
fifo.sale = obj
|
fifo.sale = obj
|
||||||
fifo.type = FIFO.FIFO_TYPE_SALE_OUT
|
fifo.type = FIFO.FIFO_TYPE_SALE_OUT
|
||||||
fifo.is_audited = False
|
fifo.is_audited = False
|
||||||
fifo.auditor = request.user
|
|
||||||
fifo.inout_date = timezone.now()
|
|
||||||
fifo.create_by = request.user
|
fifo.create_by = request.user
|
||||||
fifo.number = 'CK' + ranstr(7)
|
fifo.number = 'CK' + ranstr(7)
|
||||||
fifo.save()
|
fifo.save()
|
||||||
|
@ -95,6 +93,17 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=True, perms_map={'post':'sale_up_ship'}, serializer_class=SaleUpShipPicSerializer)
|
||||||
|
@transaction.atomic
|
||||||
|
def up_ship(self, request, pk=None):
|
||||||
|
"""
|
||||||
|
上传物流信息
|
||||||
|
"""
|
||||||
|
obj = self.get_object()
|
||||||
|
obj.ship_pic = request.data['path']
|
||||||
|
obj.save()
|
||||||
|
return Response()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,15 +78,15 @@ class UpdateDevelop(APIView):
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
import os
|
import os
|
||||||
# 更新后端
|
# 更新后端
|
||||||
os.chdir('/home/hberp')
|
os.chdir('/home/lighthouse/hberp')
|
||||||
ret = os.popen('git pull https://caoqianming%40foxmail.com:9093qqww@e.coding.net/ctcdevteam/hberp/hberp.git develop')
|
ret = os.popen('git pull https://caoqianming%40foxmail.com:9093qqww@e.coding.net/ctcdevteam/hberp/hberp.git develop')
|
||||||
# 奇怪的处理
|
# 奇怪的处理
|
||||||
os.chdir('/home/hberp/hb_server/vuedist')
|
# os.chdir('/home/hberp/hb_server/vuedist')
|
||||||
os.popen('cp index.html indexbak')
|
# os.popen('cp index.html indexbak')
|
||||||
time.sleep(1000)
|
# time.sleep(1000)
|
||||||
os.popen('rm -rf index.html')
|
# os.popen('rm -rf index.html')
|
||||||
time.sleep(1000)
|
# time.sleep(1000)
|
||||||
os.popen('mv -f indexbak index.html')
|
# os.popen('mv -f indexbak index.html')
|
||||||
# 打包前端
|
# 打包前端
|
||||||
# os.chdir('/home/hberp/hb_client')
|
# os.chdir('/home/hberp/hb_client')
|
||||||
# os.system('npm run build:prod')
|
# os.system('npm run build:prod')
|
||||||
|
|
Loading…
Reference in New Issue