from odoo import models, fields
from fastapi import APIRouter
from typing import List


class FastapiEndpoint(models.Model):
    _inherit = "fastapi.endpoint"

    app = fields.Selection(
        selection_add=[("logistics_nodes", "Logistics Nodes API")],
        ondelete={"logistics_nodes": "cascade"}
    )

    def _get_fastapi_routers(self) -> List[APIRouter]:
        if self.app == "logistics_nodes":
            from ..routers.logistics_api import router
            return [router]
        return super()._get_fastapi_routers()