Import Issue with Tryton Custom Module in VS Code

Hi,

I’ve developed a Tryton module named “umbrella” and imported some objects from this module into another custom module as shown below:

from trytond.modules.umbrella.core.response import (
    Result,
    Error,
    get_errors,
    JsonResponse,
    ErrorMessage,
)

In VS Code, the line above is underlined with the following error:

Unable to import ‘trytond.modules.umbrella.core.response’.
No name ‘umbrella’ in module ‘trytond.modules’.

Interestingly, when I run my application, it functions perfectly. However, this issue is causing several problems for me. For instance, renaming an object in the “umbrella” module doesn’t reflect in its references, code intelligence is not working, and more.

I would greatly appreciate your help in resolving this matter.

Thanks,

In Tryton you usually want to get Model from pool, after which you can call it’s methods.

It looks like you tried to import directly like you would in Python. Tryton has it’s own module system and thus Tryton must make sure that things are loaded in the right order.

See an example from the module tutorial.

Things that are imported are not models they are some helper Classes and methods that i can’t get them from the pool.

I am no VSCode user, but some people at my company uses it, and we noticed that it has a default configuration somewhere to create its own virtual environment for your project.

Does your import work in a python console ? in the VSCode terminal vs a standalone terminal ?