The plugin must follow some conventions
- Must be an pip intalable FastAPI application
- Plugin name should be prefixed with
openerp_and suffixed with_plugin - In the top level of the package, we should be able to import
- Variables
title,description,author,version - FastAPI app
api_routerwhich can be mounted in the main app - The List of
available_resources. It will be used by main application for permissions. e.g.["res_1", "res_2"] - List of requested scopes
data_scopes. It will determine what data will be available for the plugin
- Variables
- These variables will always be available inside
request.stateuser_idID of the authenticated useruser_nameName of the authenticated userhas_permissionfunction to check if the user has permissionis_superuserIf the user is superuser, if so all permissions will be availabledataAdditional data required by the plugindata_scopes
- Permissions
- For permission, you need to define the resource list first
- If that resource is not open,
create,read,update,deleteandallwill be defined automatically - If any of the operations are not available, you need to define it as
{'delete': False, 'update': False} - In endpoints, permission needs to be checked to perform the required operation on the resource
has_permission('read', 'res_1')will returnTrueif the user has permission to readres_1
For more information, check example plugin repo