As per odoo convention, we call a model instance this way
Partner = self.env['res.partner']
IDE can not suggest the methods `res.partner` model has. One reason is, `res.partner` is the value of _name attribute of original pythonic Model class name. In Odoo development, that pythonic glass name has no use. But I suspect, this class name is somehow important for typing annotation.
I would love to use this if I could import ResPartnerClass where ResPartnerClass is the pythonic Model class name of res.partner model,
Partner: ResPartnerClass = self.env['res.partner']
But finding and importing ResPartnerClass is a non-trivial job to perform since it is an internal module.
Does anybody know the solution regarding this problem?
Cette question a été signalée
Python versions less than 3.11, the Self type is available in typing_extensions . You import the Self type from typing in line 3 and annotate
If you are using PyCharm, I would recommend trying the "Odoo Framework Integration for PyCharm" Plugin by Trịnh Anh Ngọc.
It has some cost associated with it, but for me, it is worth it.
PS: Not affiliated; just a happy user. :)
PPS: I cannot post links yet due to missing Karma, but it should be the first hit on Google.
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|
|
0
janv. 23
|
2222 |