mirror of
https://github.com/himool/HimoolERP.git
synced 2024-11-10 08:55:40 +08:00
fix: 商品图片
This commit is contained in:
parent
fc005f7b24
commit
aa3fa071a4
3 changed files with 18 additions and 1 deletions
|
@ -135,6 +135,11 @@ class GoodsSerializer(BaseSerializer):
|
|||
instance = self.validate_foreign_key(GoodsUnit, instance, message='商品单位不存在')
|
||||
return instance
|
||||
|
||||
def validate_enable_batch_control(self, value):
|
||||
if value and (self.team.enable_auto_stock_in or self.team.enable_auto_stock_out):
|
||||
raise ValidationError('只有同时关闭自动入库、自动出库, 才可以开启商品的批次控制')
|
||||
return value
|
||||
|
||||
def validate_goods_images(self, instances):
|
||||
instances = self.validate_foreign_key_set(GoodsImage, instances, message='商品图片不存在')
|
||||
return instances
|
||||
|
|
|
@ -6,7 +6,7 @@ router = BaseRouter()
|
|||
router.register('goods_categories', GoodsCategoryViewSet, 'goods_category')
|
||||
router.register('goods_units', GoodsUnitViewSet, 'goods_unit')
|
||||
router.register('goods', GoodsViewSet, 'goods')
|
||||
router.register('goods_images', GoodsViewSet, 'goods_image')
|
||||
router.register('goods_images', GoodsImageViewSet, 'goods_image')
|
||||
router.register('batchs', BatchViewSet, 'batch')
|
||||
router.register('inventories', InventoryViewSet, 'inventory')
|
||||
urlpatterns = router.urls
|
||||
|
|
|
@ -3,6 +3,7 @@ from extensions.common.base import *
|
|||
from extensions.serializers import *
|
||||
from extensions.exceptions import *
|
||||
from apps.system.models import *
|
||||
from apps.goods.models import *
|
||||
|
||||
|
||||
class PermissionGroupSerializer(BaseSerializer):
|
||||
|
@ -26,6 +27,17 @@ class SystemConfigSerializer(BaseSerializer):
|
|||
model = Team
|
||||
fields = ['enable_auto_stock_in', 'enable_auto_stock_out']
|
||||
|
||||
def validate_enable_batch_control(self, value):
|
||||
if value and (self.team.enable_auto_stock_in or self.team.enable_auto_stock_out):
|
||||
raise ValidationError('只有同时关闭自动入库、自动出库, 才可以开启商品的批次控制')
|
||||
return value
|
||||
|
||||
def validate(self, attrs):
|
||||
if attrs['enable_auto_stock_in'] or attrs['enable_auto_stock_out']:
|
||||
if goods := Goods.objects.filter(enable_batch_control=True, team=self.team).first():
|
||||
raise ValidationError(f'商品[{goods.name}]已开启批次控制, 无法开启自动出/入库')
|
||||
return super().validate(attrs)
|
||||
|
||||
|
||||
class RoleSerializer(BaseSerializer):
|
||||
|
||||
|
|
Loading…
Reference in a new issue