1
from typing import Optional, List
3
from fastapi_filter.contrib.sqlalchemy import Filter
4
from pydantic.types import UUID4
5
from core.schemas.basic_schemes import BasicField as Field, bollean
7
from app.inventory.location.enums import LocationClass
8
from app.inventory.location.models import Location
9
from core.schemas import BaseFilter
10
from core.schemas.basic_schemes import BasicModel
11
from core.schemas.list_schema import GenericListSchema
12
from core.schemas.timestamps import TimeStampScheme
15
class LocationBaseScheme(BasicModel):
16
vars: Optional[dict] = None
17
location_class: LocationClass
19
store_id: UUID4 = Field(title='Store', model='store')
20
location_id: Optional[UUID4] = Field(default=None, title='Parent Location', model='location')
21
is_active: bollean = Field(default=True, title='Is Active')
22
location_type_id: UUID4 = Field(title='Location Type', model='location_type')
23
partner_id: Optional[UUID4] = Field(default=None, title='Partner', model='partner')
25
location_class: LocationClass = Field(default=LocationClass.PLACE, title='Location Class')
26
lot_id: Optional[UUID4] = Field(default=None, title='Lot')
27
is_can_negative: bollean = Field(default=False, title='Can Negative')
28
allowed_package_ids: Optional[list[UUID4]] = Field(default=[], title='Allowed Packages')
29
exclude_package_ids: Optional[list[UUID4]] = Field(default=[], title='Exclude Packages')
33
from_attributes = True
36
class LocationUpdateScheme(LocationBaseScheme):
40
class LocationCreateScheme(LocationBaseScheme):
44
class LocationScheme(LocationCreateScheme, TimeStampScheme):
45
company_id: UUID4 = Field(model='company', title='Company')
50
from_attributes = True
53
class LocationFilter(BaseFilter):
54
title: Optional[str] = Field(default=None, title='Title')
55
store_id__in: Optional[List[UUID4]] = Field(default=None, title='Store', model='store')
56
location_type_id__in: Optional[List[UUID4]] = Field(default=None, title='Location Type', model='location_type')
57
location_class__in: Optional[List[LocationClass]] = Field(default=None, title='Class')
58
location_class__not_in: Optional[List[LocationClass]] = Field(default=None, title='Class')
59
is_active: Optional[bool] = Field(default=None, title='Active')
60
is_can_negative: Optional[bool] = Field(default=None, title='Is can negative')
62
class Constants(Filter.Constants):
64
ordering_field_name = "order_by"
65
search_field_name = "search"
66
search_model_fields = ["title"]
69
class LocationListSchema(GenericListSchema):
70
data: Optional[List[LocationScheme]]