50 lines
1.0 KiB
Python
50 lines
1.0 KiB
Python
import uuid
|
|
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from . import to_camel
|
|
from .product_group import ProductGroupLink
|
|
from .stock_keeping_unit import StockKeepingUnit
|
|
|
|
|
|
class ProductLink(BaseModel):
|
|
id_: uuid.UUID = Field(...)
|
|
name: Optional[str]
|
|
|
|
class Config:
|
|
fields = {"id_": "id"}
|
|
|
|
|
|
class ProductIn(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
fraction_units: str = Field(..., min_length=1)
|
|
skus: List[StockKeepingUnit]
|
|
product_group: ProductGroupLink = Field(...)
|
|
is_active: bool
|
|
is_purchased: bool
|
|
is_sold: bool
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
|
|
|
|
class Product(ProductIn):
|
|
id_: uuid.UUID
|
|
code: int
|
|
is_fixture: bool
|
|
|
|
|
|
class ProductBlank(ProductIn):
|
|
name: str
|
|
fraction_units: str
|
|
skus: List[StockKeepingUnit]
|
|
product_group: Optional[ProductGroupLink] # type: ignore[assignment]
|
|
is_fixture: bool
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|