lavkach3
1import uuid2from typing import Optional3
4from sqlalchemy import ForeignKey, Uuid5from sqlalchemy.orm import Mapped, mapped_column6
7from app.inventory.location.enums import LocationClass8
9
10class LocationMixin:11store_id: Mapped[uuid.UUID] = mapped_column(Uuid, index=True)12location_class: Mapped[LocationClass] = mapped_column(index=True)13lot_id: Mapped[Optional[uuid.UUID]] = mapped_column(ForeignKey("lot.id", ondelete="SET NULL"), index=True)14partner_id: Mapped[Optional[uuid.UUID]] = mapped_column(Uuid, index=True, nullable=True)15
16
17class StockMixin(LocationMixin):18product_id: Mapped[uuid.UUID] = mapped_column(Uuid, index=True)19location_type_id: Mapped[Optional[uuid.UUID]] = mapped_column(ForeignKey("location_type.id", ondelete="SET NULL"), index=True)20location_id: Mapped[Optional[uuid.UUID]] = mapped_column(ForeignKey("location.id", ondelete="SET NULL"), index=True)