Sunday, August 11, 2024
3 changes · saas-17.2
Miscellaneous changes
This commit adapts the `analytic_distribution` field with `filtered_domain` method. Since the `analytic_distribution` field is a JSON field, it is not natively supported by the methods (search, filtered_domain, etc.). The `analytic.mixin` mixin already handles `search` and `read_group` by applying its own logic in overrides of these. This fix is therefore similar and overrides `filtered_domain` and `mapped` (which is used by the latter). An example of a flow where this case is problemat
Original PR description
This commit adapts the `analytic_distribution` field with `filtered_domain` method. Since the `analytic_distribution` field is a JSON field, it is not natively supported by the methods (search,…
This commit adapts the `analytic_distribution` field with `filtered_domain` method.
Since the `analytic_distribution` field is a JSON field, it is not natively supported by the methods (search, filtered_domain, etc.). The `analytic.mixin` mixin already handles `search` and `read_group` by applying its own logic in overrides of these.
This fix is therefore similar and overrides `filtered_domain` and `mapped` (which is used by the latter).
An example of a flow where this case is problematic is when adding an approval rule via studio (a feature enabling, for example, some methods/buttons to be clickable only if the user is authorized).
To do this, the user must enter a domain, thus filtering the records on which he wishes to apply the approval rule.
In our case, using “analytic_distribution” in a domain doesn't work, because studio uses a `filtered_domain` to find out whether the current record corresponds to the condition set by the domain.
But once in `filtered_domain` we arrive here
https://github.com/odoo/odoo/blob/b527b8643400f4bca74aeb397cde9e5d260f01ff/odoo/models.py#L6203-L6204
`record.mapped(key)` where key is `analytic_distribution` returns the entire JSON object, in the form of an object array containing as key a comma-separated list of ids whose value is a float, for example: `{“16,17”: 100.0}`.
Since our domain in this case looks something like `[“analytic_distribution”, “=”, “Administrative”]`
we compare `Administrative` with `{“16,17”: 100.0}` and `filtered_domain` returns False and our record is never detected.
So this fix is in two parts,
first, we make sure that mapped doesn't return the whole `analytic_distribution` object, but just the values we're interested in: the ids. To do this, we use the method already available in `analytic.mixin`: `_get_analytic_account_ids`.
So instead of comparing `Administrative` with `{“16,17”: 100.0}`, we'll compare the id directly, so something like comparing `Administrative` with `[16,17]`.
Now that we have a clean list of ids, we can replace the display name `Administrative` with its id to compare ids with ids.
To do this, we'll override `filtered_domain` so that if we call it with the following domain `[“analytic_distribution”, “=”, “Administrative”]`, we'll rewrite the domain to facilitate the final call of the real `filtered_domain` method. The result is: `[“analytic_distribution”, “=”, [17]]`.
Proceed in the same way as in `_search_analytic_distribution` to retrieve the id using a `name_search`.
https://github.com/odoo/odoo/blob/d6bdb05771fd29a79f2e8087b92a438fec28afaa/addons/analytic/models/analytic_mixin.py#L51-L58
opw-4002202
Forward-Port-Of: odoo/odoo#175018Description of the issue/feature this PR addresses: When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to `_get_query_currency_table`, this can lead to a KeyError when [fetching the rate ](https://github.com/odoo/odoo/blob/2130b3bbe627d97b41bbb9a93ff407c2990560a3/addons/account/models/res_currency.py#L65)for said company. Current behavior before PR: Steps to reproduce: - Create company 2 w
Original PR description
Description of the issue/feature this PR addresses: When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies…
Description of the issue/feature this PR addresses: When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to `_get_query_currency_table`, this can lead to a KeyError when [fetching the rate ](https://github.com/odoo/odoo/blob/2130b3bbe627d97b41bbb9a93ff407c2990560a3/addons/account/models/res_currency.py#L65)for said company. Current behavior before PR: Steps to reproduce: - Create company 2 with a currency different than the original company - Deactivate the original company - Install module Purchase (or another module that uses `_get_query_currency_table`) - failure Same behavior on upgrade if purchase is already installed and the company linked to the system user is deactivated and has a different currency than the active companies. Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#171605
The "active records" toggle from the domain editor was invisible in darkmode because it has a whit/transparent image over a forces white background. This revision forces a dak background limited to the toggle button so that it becomes visible again. Task-4081249 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 Forward-
Original PR description
The "active records" toggle from the domain editor was invisible in darkmode because it has a whit/transparent image over a forces white background. This revision forces a dak background limited to the toggle button so that it becomes visible again. Task-4081249 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 Forward-Port-Of: odoo/odoo#174857