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?
This question has been flagged
2
Replies
3304
Views
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.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
0
Jan 23
|
2214 |