forked from erp-dev/erp
feat: added type field into warehouse model
This commit is contained in:
@@ -102,11 +102,27 @@ class SupplierSerializer(BaseSerializer):
|
||||
|
||||
|
||||
class EmployeeSerializer(BaseSerializer):
|
||||
job_type = serializers.CharField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = basic_models.Employee
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class EmployeeTypeSerializer(BaseSerializer):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# 移除 unique_together 验证器中对 merchant 的要求
|
||||
# 因为 merchant 会在 perform_create 中自动设置
|
||||
for validator in self.validators:
|
||||
if hasattr(validator, 'fields') and 'merchant' in validator.fields:
|
||||
validator.fields = tuple(f for f in validator.fields if f != 'merchant')
|
||||
|
||||
class Meta:
|
||||
model = basic_models.EmployeeType
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CustomerSerializer(BaseSerializer):
|
||||
created_by = serializers.PrimaryKeyRelatedField(
|
||||
queryset=basic_models.Employee.objects.all(),
|
||||
|
||||
Reference in New Issue
Block a user