ii have fastapi api and odoo17 enterprise project and i need one feature, when commenting on orders employees user should comment them all and then send it to me, like if user have order that needs 10 employees from service, user should comment and rate them all and then send submit at once, mobile part is in flutter and they are other team, we need to figure out about api for this needs, i will send you some of my files:from typing import Annotated, List, Optional
from fastapi import APIRouter, Depends, HTTPException, Request
from pydantic import BaseModel
from odoo.api import Environment
from odoo.addons.fastapi_addon.schemas.base_schema import PagedCollection, Paging
from odoo.addons.fastapi_addon.schemas.employee_schema import EmployeeSchema, EmployeeRateRequest, EmployeeRateResponse
from ..dependencies import odoo_env, paging
from odoo.addons.fastapi_addon.utils.media_url import get_media_url
from ..dependencies import odoo_env, paging, get_partner
from odoo.addons.base.models.res_partner import Partner
from odoo import _

router = APIRouter(tags=["Employees"])


@router.get("/service/{service_id}/employees", response_model=PagedCollection[EmployeeSchema])
async def get_employees_by_service(
    service_id: int,
    env: Annotated[Environment, Depends(odoo_env)],
    request: Request
):
    """
    Get employees related to a specific service along with their ratings.
    """
    # Search for the service record by ID
    service = env["msk.service"].sudo().search([("id", "=", service_id)], limit=1)

    # Check if the service exists
    if not service:
        raise HTTPException(status_code=404, detail=_("Service not found"))

    # Fetch related employees
    employees = service.employee_ids
    count = len(employees)

    # Prepare employee data with rating calculation
    items = []
    total_rating = 0
    total_ratings_count = 0

    for employee in employees:
        # Fetch ratings for each employee
        ratings = env["employee.rate"].sudo().search([("employee_id", "=", employee.id)])

        # Calculate the average rating for the employee
        employee_rating = 0
        if ratings:
            employee_rating = sum(rating.rate for rating in ratings) / len(ratings)
            total_rating += employee_rating
            total_ratings_count += 1

        # Append employee data to the list
        items.append(
            EmployeeSchema(
                id=employee.id,
                full_name=employee.full_name,
                phone_number=employee.phone_number,
                avatar=get_media_url(employee._name, employee.id, 'avatar') if employee.avatar else None,
                is_head_of_staff=employee.is_head_of_staff,
                gender=employee.gender,
                average_rating=round(employee_rating, 2) if employee_rating else None,
            )
        )

    return PagedCollection[EmployeeSchema](
        count=count,
        current=str(request.url),
        items=items
    )


@router.post("/rate/employee/{employee_id}", response_model=EmployeeRateResponse)
async def rate_employee(
        data: EmployeeRateRequest,
        employee_id: int,
        env: Annotated[Environment, Depends(odoo_env)],
        partner: Annotated[Partner, Depends(get_partner)]
):
    employee = env['employee'].sudo().search([('id', '=', employee_id)])

    if not employee:
        return HTTPException(status_code=404, detail=_('Employee Not Found'))

    if not (1 <= data.rate <= 5):
        raise HTTPException(status_code=400, detail=_('Rate must be an integer between 1 and 5'))

    employee_rate = env['employee.rate'].sudo().create({
        'name': data.content,
        'rate': data.rate
    })
    return EmployeeRateResponse(
        id=employee_rate.id,
        content=employee_rate.name,
        rate=employee_rate.rate
    )

from pydantic import BaseModel
from typing import Annotated, List, Optional


class EmployeeSchema(BaseModel):
    id: int
    full_name: str
    phone_number: str
    avatar: Optional[str]
    is_head_of_staff: bool
    gender: str
    average_rating: Optional[float]


class EmployeeRateRequest(BaseModel):
    content: str
    rate: int


class EmployeeRateResponse(BaseModel):
    id: int
    content: str
    rate: int
class OrderMskService(models.Model):
    _name = "order.msk.service"
    _description = _("Order MSK Service")
    _rec_name = "order_number"

    msk_service_id = fields.Many2one('msk.service', string=_('MSK Servis'), readonly=True)
    price_for_call = fields.Float(string=_("Price For Call"), readonly=True)
    price_for_service = fields.Float(string=_("Price For Service"))
    status = fields.Selection(
        [
            ("in_review", _("In Review")),
            ("in_progress", _("In Progress")),
            ("payment_pending", _("Payment Pending")),
            ("finished", _("Finished")),
            ('cancelled', _('Cancelled')),
            ('rejected', _('Rejected')),
        ],
        string=_('Status'),
        group_expand='_expand_status'
    )
    order_number = fields.Char(string=_("Order Number"), readonly=True)
    home_id = fields.Integer(string=_("Home"), readonly=True)
    home_info = fields.Text(string=_('Home Info'), readonly=True)
    user_id = fields.Integer(string=_("User"), readonly=True)
    start_time = fields.Datetime(string=_("Order Start Time"))
    end_time = fields.Datetime(string=_("Order End Time"))
    payment_method = fields.Selection(
        [("cash", _("Cash")), ("card", _("Credit Card"))], string=_("Payment Method"), readonly=True
    )
class Employee(models.Model):
    _name = "employee"
    _description = _("Employee")
    _rec_name = "full_name"

    full_name = fields.Char(string=_("Full Name"))
    phone_number = fields.Char(string=_("Phone Number"))

    avatar = fields.Binary(string=_("Rasm"))
    msk_id = fields.Many2one("res.users", string=_("MSK"))
    is_head_of_staff = fields.Boolean(default=False, string=_("Is Head Of Staff"))
    gender = fields.Selection(
        [("erkak", _("Erkak")), ("ayol", _("Ayol"))],
        string=_("Jinsi"),
        default="erkak"  # Default value set to "erkak" (male)
    )
    language = fields.Selection(
        [("uzbekcha", _("Uzbekcha")), ("pусский", _("Русский"))],
        string=_("Til"),
        default="uzbekcha"  # Default value set to "uzbekcha"
    )
    telegram_id = fields.Char(string=_("Telegram ID"))
    mahalla_service_id = fields.Many2many("msk.service", string=_("MSK Xizmatlari"))
    order_ids = fields.Many2many('order.msk.service', string=_("Orders"))

    employee_order_msk_service = fields.One2many(
        "employee.order.msk.service",
        "order_msk_service_id",
        string=_("Employee Order Services"),
    )
    current_order_id = fields.Integer(_("Current Order Id"))
    employee_ids = fields.Many2many("employee", string=_("Select Employees"))