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?
Pertanyaan ini telah diberikan tanda
2
Replies
3309
Tampilan
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.
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar| Post Terkait | Replies | Tampilan | Aktivitas | |
|---|---|---|---|---|
|
|
0
Jan 23
|
2216 |