Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
5322 Visninger

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
Kassér
Bedste svar

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
Kassér
Forfatter

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 Besvarelser Visninger Aktivitet
1
jan. 23
4939
3
aug. 25
2228
1
maj 25
2507
1
apr. 25
3497
1
apr. 25
4324