Finishing ForeignKey Migration and handling of their None values

This commit is contained in:
2025-05-03 21:51:56 +02:00
parent 4f0d943e04
commit 90a46ada2d
3 changed files with 14 additions and 45 deletions

View File

@@ -4,7 +4,7 @@ from typing import List, Literal, Optional
from pydantic import Field, BaseModel
from beanie import Indexed, PydanticObjectId
from firm.core.models import CrudDocument
from firm.core.models import CrudDocument, ForeignKey
from firm.core.filter import Filter, FilterSchema
@@ -39,16 +39,7 @@ class Individual(EntityType):
class Employee(BaseModel):
position: Indexed(str) = Field(title='Poste')
entity_id: PydanticObjectId = Field(
foreignKey={
"reference": {
"resource": "entities",
"schema": "Entity",
"condition": "entity_data.type=individual"
}
},
title='Employé'
)
entity_id: PydanticObjectId = ForeignKey("entities", "Entity", title='Employé')
class Config:
title = 'Fiche Employé'