Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5325 Zobrazení

working in Pycharm CE (latest) on Ubuntu 22.04

in my folder models i have a .py file which contains first line as:
from odoo import api, fields, models

pycharm is underlining all 3 api, fields and models
when mouse hover on models it is showing error as below:
cannot find reference 'models' in 'imported module odoo'

i can start the odoo server, upgrade my application/module and run it successfully.
i am curius why it is showing those errors? what it means?
regards

Avatar
Zrušit
Nejlepší odpověď

Hi,

The errors you're seeing in PyCharm regarding the api, fields, and models modules from Odoo are likely due to PyCharm's static code analysis not being able to resolve the import correctly. This can happen because Odoo uses a dynamic import system that PyCharm may not fully understand.


However, it's important to note that these errors/warnings in PyCharm do not necessarily indicate an actual issue with your code or the functionality of your Odoo application. If you can start the Odoo server, upgrade your module, and run it successfully, it suggests that your code is correct.


If you want to suppress these specific warnings in PyCharm, you can use a comment to disable the inspection for the affected line. Here's an example:


# noinspection PyUnresolvedReferences
from odoo import models, fields, api, _


Adding the # noinspection PyUnresolvedReferences comment before the import statement tells PyCharm to ignore the unresolved reference warning for that line.

Hope this will help you
Thanks 

Avatar
Zrušit
Autor

thanks very much for detailed explaination and help how i can ignore this kind of errors / warnings. it was a bit irritating for me and some times confusing too. anyway, now with your help i can ignore them.

Related Posts Odpovědi Zobrazení Aktivita
1
led 23
4943
3
srp 25
2234
1
kvě 25
2510
1
dub 25
3498
1
dub 25
4327