feat: 基础数据导入导出

This commit is contained in:
Czw996 2022-03-12 23:01:26 +08:00
parent 4ea2748d14
commit 15d5e5cc08
3 changed files with 4 additions and 5 deletions

View file

@ -125,7 +125,6 @@ class SupplierSerializer(BaseSerializer):
class SupplierImportExportSerializer(BaseSerializer):
number = CharField(label='编号(必填唯一)')
name = CharField(label='名称(必填唯一)')
level = CharField(required=False, label='等级[0/1/2/3](默认: 0)')
contact = CharField(required=False, label='联系人')
phone = CharField(required=False, label='手机号')
email = CharField(required=False, label='邮箱')
@ -138,7 +137,7 @@ class SupplierImportExportSerializer(BaseSerializer):
class Meta:
model = Supplier
fields = ['number', 'name', 'level', 'contact', 'phone', 'email', 'address', 'bank_account',
fields = ['number', 'name', 'contact', 'phone', 'email', 'address', 'bank_account',
'bank_name', 'remark', 'order', 'is_active']

View file

@ -189,7 +189,7 @@ class ClientViewSet(ModelViewSet, DataProtectMixin, ExportMixin, ImportMixin):
client_items = import_serializer.validated_data
client_numbers = {item['number'] for item in client_items}
client_set = client.objects.filter(number__in=client_numbers, team=self.team)
client_set = Client.objects.filter(number__in=client_numbers, team=self.team)
create_client_set = []
update_client_set = []

View file

@ -205,7 +205,7 @@ class GoodsViewSet(ModelViewSet, DataProtectMixin, ExportMixin, ImportMixin):
for goods_item in goods_items:
goods_item['team'] = self.team
category_item = goods_items.pop('category', None)
category_item = goods_item.pop('category', None)
if category_item:
for category in category_set:
if category.name == category_item['name']:
@ -214,7 +214,7 @@ class GoodsViewSet(ModelViewSet, DataProtectMixin, ExportMixin, ImportMixin):
else:
raise ValidationError(f'分类缺失[{category_item["name"]}]')
unit_item = goods_items.pop('unit', None)
unit_item = goods_item.pop('unit', None)
if unit_item:
for unit in unit_set:
if unit.name == unit_item['name']: