Thursday, April 20, 2023
7 changes · master
Enhancements to existing features
Employee lookup in HR contracts and attendance now supports searching by either registration number or employee name. This makes it faster for users to find the right employee when filtering or selecting HR records.
Original PR description
This change adds a filter_domain attribute to the employee_id field. The filter_domain is set to filter the employee_id based on either the registration number or name of the employee. This will allow for easier searching and filtering of employees in the system. task-3130593 Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
This update lets Odoo's internal web test helper accept more request options, such as query parameters. It makes automated tests easier to write and maintain without changing normal user-facing behavior.
Original PR description
**Current behavior before PR:** The odoo.tests.common.HttpCase.url_open method wraps requests.Session.get/post/head, but is unable to use the full range of their functionality. **Desired behavior after PR is merged:** It will be possible to run tests passing alternative kwargs, such as params. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Replaces #54868.
This update prepares the web editor so multiple users can work together more reliably in Knowledge articles, including when embedded Odoo views are inserted. It improves synchronization, protects non-editable embedded content, and helps avoid missing updates between collaborators.
Original PR description
# Editor changes to enable the collaborative mode in Knowledge Here are the necessary changes to make it possible to enable the collaborative mode in Knowledge. Knowledge commands introduce a new…
# Editor changes to enable the collaborative mode in Knowledge
Here are the necessary changes to make it possible to enable the collaborative
mode in Knowledge. Knowledge commands introduce a new kind of editor blocks:
`Behaviors`, which are OWL `Component` which need to be mounted. This mounting
is asynchronous and this has to be supported, while not all nodes are observed
by the editor, meaning that parts of a `Behavior` can be collaborative while
others may not.
The following is a brief introduction for every commit in this PR, check them
out individually for more detail.
### [FIX] web_editor: notify current step when joining a collaborator
- Inserting an embedded view from a module in an automated process happens as
soon as the first collaborator connect. This commit notifies the step for the
embedded view during the following collaborators connections (to be sure they
actually received it).
### [IMP] web_editor: fully implement oeProtected and oeTransientContent
- Those attributes will allow a fine control on which nodes are NOT observed by
the editor (`oeProtected="true"`), and which nodes are NOT saved/serialized
for collaboration by the editor (`oeTransientContent="true"`). It can be a
better choice than using `observerUnactive` which stops the observer for all
nodes of the editor, in case a node should never be observed.
### [IMP] web_editor: prevent 'insert' command unwrapping in root
- Modify the 'insert' command of the editor so that it does not unwrap nodes
when the selection is directly inside the editable ('root'). Unwrapping a
paragraph in that case would put text nodes as direct childs of the editable,
which is not desirable with the current implementation.
### [IMP] web_editor: add a hook for historyResetFromSteps
- When joining an `html_field` in collaborative mode, there is no way to know if
there are connected collaborators before actually making said connection. This
is a problem when we want to automate the insertion of an embedded view from
another module in Knowledge. With the hook, it is now possible to execute a
specific action as soon as a collaborator is joined.
### [IMP] web_editor: force load collaborative on form view
- The collaborative mode loads lazily with the focus by default. In Knowledge it
should start as soon as possible, therefore this commit adds an option to do
so.
### [IMP] web_editor: make mocha tests odoo modules
- Since `web_editor` tests were not odoo modules, it was not possible to import
dependencies from i.e. `web`. This commit addresses that.
### [IMP] web_editor: buffer external steps during Component rendering
- In a collaboration, when applying a step requiring a custom OWL `mount`
(which is asynchronous), further external steps should be buffered while the
rendering is done, in case those following external steps should concern
"rendered" nodes which are not yet present in the editor. Once all nodes are
rendered and present in the editor, further steps can be applied safely.
See odoo/enterprise#33483
See odoo/upgrade#4384Users can now use saved favorites inside Knowledge embedded views, making it easier to reuse preferred filters and views in shared content. This improves consistency and convenience when working with embedded Odoo data in Knowledge.
Original PR description
Purpose ======= Allow to use favorite in Knowledge embedded view. For that purpose, we need to hook some function in the web module (because the favorite are store in the view arch, and not with ir.filters records). Task-3251129
This update prepares the Knowledge app for real-time collaborative editing by making complex Knowledge blocks safer to render, save, and share between users. Collaboration is not enabled yet because related editor issues still need to be fixed, but the changes reduce future data-loss risk and improve readiness for multi-user editing.
Original PR description
# Implement the collaborative mode in Knowledge /!\ This PR does not enable the collaborative mode in Knowledge, because some collaborative errors are in the process of being fixed in the…
# Implement the collaborative mode in Knowledge /!\ This PR does not enable the collaborative mode in Knowledge, because some collaborative errors are in the process of being fixed in the `web_editor` module. see task: 3217965, as well as the traceback `InvalidStateError, failed to execute setRemoteDescription on RTCPeerConnection`, which will be investigated soon. In the meantime, the `collaborative` option of the html_field should stay `false`, because there is a risk of data loss as long as those bugs are present. Here are the necessary changes to make it possible to enable the collaborative mode in Knowledge. Knowledge commands introduce a new kind of editor blocks: `Behaviors`, which are OWL `Component` which need to be mounted. This mounting is asynchronous and this has to be supported, while not all nodes are observed by the editor, meaning that parts of a `Behavior` can be collaborative while others may not. The following is a brief introduction for every commit in this PR, check them out individually for more detail. ### [MOV] knowledge: move the abstract_behavior wysiwyg template - Move the abstract_behavior wysiwyg template with other similar templates in `knowledge_editor.xml` ### [IMP] knowledge: remove duplicate editor getter - The `get editor` was unnecessarily overrided with the same implementation. ### [IMP] knowledge: fully implement oeProtected and oeTransientContent - Those attributes will allow a fine control on which nodes are NOT observed by the editor (oeProtected="true"), and which nodes are NOT saved/serialized for collaboration by the editor (oeTransientContent="true"). It allows `Behavior` OWL lifecycle steps (like `onMounted`, `onPatched`) to not use the `observerUnactive` method to make changes in the editor, which was hazardous as some steps are asynchronous (so there could be a lock active during an asynchronous task). - Every `Behavior` is now `oeProtected="true"` by default, and can specify which of its sub-nodes are `oeProtected="false"` (meaning they should be observed by the editor and collaborative). - An usage example of `oeTransientContent="true"` is an embedded view, as its content is generated dynamically each time, and in the context of the current user, meaning that sharing those nodes in collaboration or saving them in the database does not make sense. - As OWL `mount` is asynchronous, this commit introduces a way to "pre-render" `Behaviors` in a `d-none` div aside the editable, so that the `Behavior` fully rendered can be inserted at once in the editable. (this is to avoid generating multiple `add` mutations during the rendering process, which could be decoupled in collaboration, breaking the rendering logic.) ### [IMP] knowledge: avoid OWL instructions in unprotected Behavior nodes - OWL template instructions can add empty text nodes in the DOM after rendering (i.e `t-if`, `t-else`). If those nodes are observed by the editor (under a `oeProtected="false"` parent), this means that functionnally identical content could have technical differences and not be considered the same by the editor. As such, the current solution is to avoid those instructions under a `oeProtected="false"` parent and handle conditional content manually in the `Component`. ### [IMP] knowledge: make articles structures collaborative - The /index command creates a block with content generated by OWL, so we are exactly in the case mentionned in the previous commit. That content should thus be handled outside of the OWL template. And this requirement is reinforced by the fact that we want to let the editor override those rendered nodes from a collaborator mutation (external step). (OWL crashes if its rendered nodes are modified without its consent). - Therefore this commit introduces the necessary changes for that command to work properly in collaboration. ### [IMP] knowledge: setup embedded view intersectionObserver in editable - The intersection observer for embedded views does not catch the moment when a "pre-rendered" node is moved from the `d-none` rendering zone to the editable. Therefore it is only set up once in the editable, with the usage of a temporary mutation observer. ### [IMP] knowledge: insert external embedded views in collaboration - When joining an html_field in collaborative mode, there is no way to know if there are connected collaborators before actually making said connection. This is a problem when we want to automate the insertion of an embedded view from another module in Knowledge. - This commit uses the hook introduced in `web_editor` to attempt the insertion a second time if the content received from the database where the embedded view was inserted the first time is reset from the currently active collaborator when the current user joins him in collaboration (`onHistoryResetFromSteps`). ### [IMP] knowledge: buffer external steps during Component rendering - In a collaboration, when applying a step requiring a custom OWL `mount` (which is asynchronous), further external steps should be buffered while the rendering is done, in case those following external steps should concern "rendered" nodes which are not yet present in the editor. Once all nodes are rendered and present in the editor, further steps can be applied safely. - This commit uses the option introduced in `web_editor` to provide a promise when it detects that a step added a new `Behavior` anchor node, and that promise will be resolved when the `Behavior` is fully rendered and ready. See odoo/odoo#104680 See odoo/upgrade#4384
Knowledge users can now save favorites such as default searches and groupings directly inside embedded views. These favorites stay specific to each embedded view, making repeated analysis easier without affecting other views.
Original PR description
Purpose ======= Support favorite in embedded views and be able to have default search, group by, etc... Specification ============= The favorite / default search - group by, are defined per view. It means that if you create a favorite for an embedded view, it won't be visible for the other views (even if they share the same parent). Technical ========= The favorite are saved in the HTML arch of the view, instead of creating real `ir.filters` records. The reason is that `ir.filters` are defined for an action, or for the entire model. Embedded view have no action and no id, they are just inserted into the HTML body. If we wanted to create a special model for that, we would have need to clean those records in a CRON, which means parsing HTML to know which view has been removed, etc. So it made more sens to store it in the arch (we remove the view from the body, we remove its filter as well). Task-3251129
The Knowledge app has been simplified by removing obsolete internal logic related to article favorites. This has no expected change for users, but it helps keep the codebase cleaner and easier to maintain.
Original PR description
Since e68d7b81a6403665355991e80ae5ab3e03260335, the inverse method for is_user_favorite field is not used anymore. This commit simply removes it. Task-3274933