Hello World Cup 2022!
To be honest, football is one of my biggest hobbies besides programming. My younger brother also loves football very much. Wish we could still watch the World Cup together. Anyway, thanks to Annie Leibovitz for the great photo I used for the cover of this blog post.
Type hints for recordset values
In the previous version (2022.6), I introduced the type hints for recordsets. In this release, I continues the story with type hints for recordset values. As you know, it's common in Odoo to create specific methods for preparing data before creating or updating recordsets. If IDEs can know about the model for which you are preparing data, it will provide code completion and navigation for fields, it will also warn if a field does not exist so you can quickly fix it.
There are two syntaxes to express type hint for a recordset dict values:
1. Use Annotated in conjunction with the magic odoo.values.*
If you are using Python >= 3.9 then this syntax is recommended because for unsupported IDEs, this syntax will be treated like the normal dict type. You can learn more about Annotated here.
2. Use the magic odoo.values.* directly
This syntax is more concise but currently it only works for PyCharm with the Odoo plugin. Unsupported IDEs will be confused and may treat it as unknown type.
When thinking of ideas for these syntaxes, I always try to keep them as concise and easy to read/write as possible. When combined with code completion, it gives the best coding experience.
Now I am going to show you some effects of these type hints that I am pretty happy with.
Code completion in values declaration:
Code completion in updating values:
Code completion in return expression:
Overriding symbols navigation improvements
The Odoo plugin has supported the following types of inheritance related navigations:
- From a model class to its super model classes (include BaseModel).
- From a model class to its extending model classes.
- From a model class attribute (field, method) to its super attributes.
- From a model class attribute (field, method) to its overriding attributes.
The only things missing were navigation from the BaseModel class to model classes and navigation from a BaseModel's attribute to its overriding attributes. So in this version I took the time to implement them.
Support inline CSS and internal CSS
The Odoo plugin now supports syntax highlight, code completion,... for inline CSS and internal CSS in views.
In addition to the above highlights, this version also includes other improvements and bug fixes. You can find the full change notes at https://plugins.jetbrains.com/plugin/13499-odoo.
Thank you all for supporting me. I hope you all have fun in the World Cup 2022 and have the most enjoyable coding experience with PyCharm and the Odoo plugin.