add products

This commit is contained in:
Julien Aldon
2026-02-12 17:39:53 +01:00
parent 025b78d5dd
commit 1a98957466
12 changed files with 129 additions and 75 deletions

View File

@@ -1,5 +1,5 @@
from sqlmodel import Field, SQLModel, Relationship
from enum import Enum
from enum import StrEnum
from typing import Optional
import datetime
@@ -44,14 +44,14 @@ class ProductorUpdate(SQLModel):
class ProductorCreate(ProductorBase):
pass
class Unit(Enum):
GRAMS = 1
KILO = 2
PIECE = 3
class Unit(StrEnum):
GRAMS = "1"
KILO = "2"
PIECE = "3"
class ProductType(Enum):
PLANNED = 1
RECCURENT = 2
class ProductType(StrEnum):
PLANNED = "1"
RECCURENT = "2"
class ShipmentProductLink(SQLModel, table=True):
shipment_id: Optional[int] = Field(default=None, foreign_key="shipment.id", primary_key=True)
@@ -62,7 +62,7 @@ class ProductBase(SQLModel):
unit: Unit
price: float
price_kg: float | None
weight: float
weight: float | None
type: ProductType
productor_id: int | None = Field(default=None, foreign_key="productor.id")
@@ -83,10 +83,10 @@ class ProductUpdate(SQLModel):
price_kg: float | None
weight: float | None
productor_id: int | None
shipment_ids: list[int] | None
shipment_ids: list[int] | None = []
class ProductCreate(ProductBase):
shipment_ids: list[int] | None
shipment_ids: list[int] | None = []
class FormBase(SQLModel):
name: str