Hello world!
This release is later than I expected. It was a really hard time for me. Work pressure sometimes drives me crazy. Because my company just completed upgrading the platform and products to Odoo 15, the work pressure has reduced a bit so I think it's time to release a new version of the Odoo plugin. Again, thank you all for your support. Without your support, it would be really difficult for me to keep the plugin going strong.
Fields incremental definition
A field is defined as class attribute on a model class. If the model is extended, one can also extend the field definition by redefining a field with the same name and same type on the subclass. In that case, the attributes of the field are taken from the parent class and overridden by the ones given in subclasses... (Odoo ORM Documentation)
Consider the following code sample:
In the previous versions, the plugin simply looked for the nearest field definition for the field information - agent_id in IdolB. Because agent_id is overridden in class IdolB with a new help string but has no comodel, the plugin could not know about the relational model of agent_id and thus could not provide suitable suggestions after typing self.agent_id.
After a lot of refactoring, the Odoo plugin now full understands fields incremental definition. The plugin now not only provides a better code completion but also a new helpful tooltips on hover:
For selection field, both initial values and additional values are taken into account.
New eval context providers
Beside Python files, Odoo uses evaluable code a lot in XML, for example:
- Dynamic view attributes: <field name="count" attrs = "{'invisible': [('count', '=', 0)]}" />
- Record rule domain: <field name="domain_force">[('user_id', '=', user.id)]</field>
- Cron code: <field name="code">model._autopost_draft_entries()</field>
- QWeb: <t t-out="request.website.sudo().robots_txt" />
The evaluable code may be Python (record rule domain, QWeb renders in backend,...), JS (QWeb renders in frontend) or PyJS (dynamic view attribute, many2one's domain attribute,...). Each evaluable code accepts certain variables. For example, you can use the following variables in the record rule domain: user, company_id, company_ids.
In the previous versions, the plugin only provided syntax highlight for these evaluable code but could not provide a good code completion for them. I've refactored how the plugin handles these cases and the results are awesome: better performance, better code completion, better extensible... Some evaluable code have been supported by the new eval context providers in this release, more will come later.
Improve selection ondelete completion
The Odoo plugin now provides full support for ondelete fallback value.
Group operator completion
The Odoo plugin now provides code completion for group_operator attribute value of fields.
Improve opened file title
The way PyCharm shows the titles of opened files sometimes confuses me. I could not tell the module of an opened file at a glance. For opened module files, the Odoo plugin now always includes the module name in the file title.
Title in window and tabs:
Title in Recent Files:
As usual, besides the above features, this release also has many bug fixes and other improvements to make PyCharm the best IDE for Odoo.
You can see the full change notes at https://plugins.jetbrains.com/plugin/13499-odoo