from rest_framework import serializers

from apps.inm.models import WareHouse,Inventory

from apps.system.serializers import UserSimpleSerializer
from apps.mtm.serializers import MaterialSimpleSerializer

class WareHouseSerializer(serializers. ModelSerializer):
    create_by_=UserSimpleSerializer('create_by', read_only=True)
    class Meta:
        model = WareHouse
        fields = '__all__'

class WareHouseCreateUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = WareHouse
        fields = ['name', 'number', 'place']

class WareHouseSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model = WareHouse
        fields = ['name', 'number', 'place']

class InventorySerializer(serializers. ModelSerializer):
    material_= MaterialSimpleSerializer(source='material', read_only=True)
    warehouse_ = WareHouseSimpleSerializer(source='material', read_only=True)
    class Meta:
        model = Inventory
        fields = '__all__'

class InventoryCreateUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = Inventory
        fields = ['material', 'count', 'warehouse']
