Thursday, November 14, 2024
2 changes
1 change
Code cleanup and technical improvements
This change restores the previous internal model naming approach after a related typing initiative was canceled. It helps keep the system aligned with established Odoo conventions without introducing functional changes for end users.
Original PR description
Following internal discussions, the python typing and inheritance task is canceled. The use of the class name instead of '_name' was done to allow notations such as `partner_id = fields.Many2one[base.ResParter](string='Partner')`. Since this notation is canceled, we put `_name` back (although the class name is sufficient). Partial revert: https://github.com/odoo/enterprise/pull/69762 https://github.com/odoo/odoo/pull/178200
1 change
Code cleanup and technical improvements
This update reorganizes how the HTML editor coordinates toolbar actions, shortcuts, power buttons, and internal editor events. It makes the editor code clearer and easier to maintain, reducing future development and debugging complexity without changing the intended user experience.
Original PR description
# Use delegate There is a common pattern in the editor plugins where we allow other plugins to take over the handling of a command. In order to make it explicit in the code, this commit introduces a…
# Use delegate There is a common pattern in the editor plugins where we allow other plugins to take over the handling of a command. In order to make it explicit in the code, this commit introduces a new utility function called delegate that will be used to call the handlers. # Use trigger In the editor, the pattern to dispatch events from one plugin to other plugins is to use the resource mechanism that aggregates callbacks to a specific resource. In order to make it clear when reading code that we want to dispatch an event, this commit introduces the util function trigger that communicates the intent to the reader. # Remove dispatch Reasons: 1) It is a redundant mechanism, we can achieve the same result though the use of shared and resources. 2) Using the shared or the resources is more explicit. If we need to call a command from a specific plugin, we should depend on the plugin and use the shared. If we need multiple plugins to react to an "event", we should use the resources. 3) We should distinguish between a "user command" and a "system command" or "system event". - A "user command" is anything that a user could configure as a shortcut, toolbar item, powerbox item, or power button. - A "system command" is a shared method. - A "system event" is a resource. 4) When debugging, it was harder to "step into" a dispatched command as we would step into the `handleCommand` of every plugins. For `toolbarItems` and `powerboxItems` now inherit the properties of a user command through the `commandId` property (if specified). The power buttons now use the definition of the user commands instead of the powerbox items. The `toolbarItem` `Component` does not includes dispatch in the props by default anymore, we need to specify the callbacks in the props of the `toolbarItem` explicitly.