feat: barcode templates
This commit is contained in:
@ -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"
|
||||
|
||||
Reference in New Issue
Block a user