I keep getting the error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
OSError: cannot open resource
when trying to import a font for PIL in my odoo module. This is my folder structure (I have left out unimportant stuff)
modulename
├── ...
├── models
│ ├── ...
│ └── engine.py
├── static
│ ├── ...
│ └── font
│ └── Inter-VariableFont_slnt,wght.ttf
└── ...
In the engine.py I am trying to import the font as following
FONTPATH = "addons/modulename/static/font/Inter-VariableFont_slnt,wght.ttf"
I have already tried all these variations
FONTPATH = "../static/font/Inter-VariableFont_slnt,wght.ttf"
FONTPATH = "~/odoo/odoo14/addons/modulename/static/font/Inter-VariableFont_slnt,wght.ttf"
FONTPATH = "./../static/font/Inter-VariableFont_slnt,wght.ttf"
I can't understand why odoo does not find the file. I have tried to specify the path relative and absoulte but it can't seem to work
The odoo instance is in a docker container which might be a problem, but it is already mounted to the filesystem and can be easily accessed just like any other folder.
The error is confusing, since the import works on my local development machine by using the absolute file path
The deployment machine, this code is running on is Linux Debian Bullseye (11)
In case important, this is how the file path is being used in the code:
h1 = ImageFont.truetype(FONTPATH, h1_height)
Thank you for your help.