You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a custom module that defines pydantic models using ExtendableBaseModel from extendable_pydantic
An example:
from extendable_pydantic import ExtendableBaseModel
from pydantic import ConfigDict
from odoo.addons.fastapi.dependencies import (
authenticated_partner,
odoo_env,
)
class ResPartnerResponse(ExtendableBaseModel, revalidate_instances='always'):
partner_id: int
partner_shipping_id: int
partner_invoice_id: int
model_config = ConfigDict(from_attributes=True)
this is defined in a custom module at the following path: custom_module/models/pydantic_models/res_partner.py
upon trying to install the module from the UI (once the modules have been loaded already) there is an error when trying to load the module, traceback below:
File "/home/antonio/dev/project/custom_module/models/pydantic_models/res_partner.py", line 69, in <module>
@main_api_router.post(
^^^^^^^^^^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/fastapi/routing.py", line 972, in decorator
self.add_api_route(
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/fastapi/routing.py", line 911, in add_api_route
route = route_class(
^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/fastapi/routing.py", line 500, in __init__
self.response_field = create_model_field(
^^^^^^^^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/extendable_pydantic/_patch.py", line 66, in _create_response_field_wrapper
_resolve_model_fields_annotation([field])
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/extendable_pydantic/_patch.py", line 30, in _resolve_model_fields_annotation
new_type = resolve_annotation(field_info.annotation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/extendable_pydantic/utils.py", line 116, in resolve_annotation
final_type = type_._get_assembled_cls(registry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/extendable/main.py", line 274, in _get_assembled_cls
return registry[cls.__xreg_name__]
~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/home/antonio/.pyenv/versions/3.11.9/envs/project_name/lib/python3.11/site-packages/extendable/registry.py", line 49, in __getitem__
return self._extendable_classes[key]
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
KeyError: 'odoo.addons.custom_module.models.pydantic_models.res_partner.ResPartnerResponse'
This isn't the case when the module is being installed using a CLI (using -i custom_module), only when the module install/upgrade gets triggered in the UI.
To Reproduce
Affected versions: 16.0
Steps to reproduce the behavior:
defining an extendable model as above
trying to install the module in the UI (after the modules have been loaded already, not via the CLI)
Expected behavior
The module can be installed with extendable pydantic models using ExtendableBaseModel.
Module
extendable
Describe the bug
We have a custom module that defines pydantic models using
ExtendableBaseModel
fromextendable_pydantic
An example:
The endpoint is defined as below:
this is defined in a custom module at the following path:
custom_module/models/pydantic_models/res_partner.py
upon trying to install the module from the UI (once the modules have been loaded already) there is an error when trying to load the module, traceback below:
This isn't the case when the module is being installed using a CLI (using
-i custom_module
), only when the module install/upgrade gets triggered in the UI.To Reproduce
Affected versions: 16.0
Steps to reproduce the behavior:
Expected behavior
The module can be installed with extendable pydantic models using
ExtendableBaseModel
.library versions:
extendable==1.2.2
extendable_pydantic==1.3.2
The text was updated successfully, but these errors were encountered: