feat: barcode templates

This commit is contained in:
2025-10-04 10:13:24 +04:00
parent 9c9b3f4706
commit 66b50fb951
11 changed files with 432 additions and 3 deletions

View File

@ -1,8 +1,15 @@
from typing import Optional
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from models.base import BaseModel
from models.mixins import IdMixin, SoftDeleteMixin
from modules.fulfillment_base.models import (
ProductBarcode,
BarcodeTemplate,
ProductBarcodeImage,
)
class Product(BaseModel, IdMixin, SoftDeleteMixin):
@ -28,6 +35,22 @@ class Product(BaseModel, IdMixin, SoftDeleteMixin):
cascade="all, delete-orphan",
)
barcodes: Mapped[list["ProductBarcode"]] = relationship(
back_populates="product",
cascade="all, delete-orphan",
)
barcode_template_id: Mapped[Optional[int]] = mapped_column(
ForeignKey("barcode_templates.id")
)
barcode_template: Mapped["BarcodeTemplate"] = relationship(lazy="joined")
barcode_image: Mapped["ProductBarcodeImage"] = relationship(
back_populates="product",
lazy="joined",
uselist=False,
)
class ProductImage(BaseModel, IdMixin):
__tablename__ = "fulfillment_base_product_images"