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=[('orders', 'Orders API')],
        ondelete={'orders': 'cascade'}
    )

    def _get_fastapi_routers(self) -> List[APIRouter]:
        if self.app == 'orders':
            from ..routers.orders_api import router
            return [router]
        return super()._get_fastapi_routers()