pycharm-odoo
pycharm-odoo copied to clipboard
Cannot find reference on "self.env.user".
It seems whatever attribute I attempt to get from "self.env.user" is treated as a function.
Hello @V3st1g3 ,
What version of PyCharm and Odoo plugin are you using?
I am using PyCharm 2024.2.1 and Odoo plugin 2024.7.0.242.
@V3st1g3 ,
Your problem is strange. I just tested and could not reproduce the problem.
Can you take a screenshot of the code completion for res.users members after typing self.env.user. ?
This is what I get.
@V3st1g3 ,
Have you tried navigating to the definitions of env and user in self.env.user? Where are the destinations?
For "env", I get "Cannot find declaration to go to". For "user", it goes to "api.py".
@V3st1g3 ,
How does your project structure look? This is my project structure:
It's quite the same except for "odoo-stubs". Should I try to add it ?
OK, now it works with "odoo-stubs" added. Sorry for wasting your time. 🙏
@V3st1g3 ,
The Odoo plugin will attach odoo-stubs automatically unless it cannot detect your Odoo version.
Indeed, I never needed to do it manually. I am using a remote interpreter from a Docker image like I always did. In the case it cannot detect my Odoo version, is there a way to "tell" it?
@V3st1g3 ,
Currently there is no manually way to tell it. If the Odoo source code directory (contains odoo-bin) is not the root directory in the project structure, then you need to mark it as Sources in the Project Structure setting, so the Odoo plugin can discover it: