[FIX] web: favorite domain is a string
Since the refactoring of the search model https://github.com/odoo/odoo/commit/aeb8e49972f871b0c9b07c507987ee77cf5e8abd, the new favorite items were created with a domain with the wrong type: Array instead of string. Thus it was impossible to share the search state with a legacy view when a new favorite was created. We now set correctly the domain key of a favorite. closes odoo/odoo#76368 X-original-commit: 2db799d53ad8e765ac864e27e5734046e0491ea9 Related: odoo/enterprise#20778 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
This commit is contained in:
@@ -1405,7 +1405,7 @@ export class SearchModel extends EventBus {
|
||||
* @param {boolean} [params.raw=false]
|
||||
* @param {boolean} [params.withSearchPanel=true]
|
||||
* @param {boolean} [params.withGlobal=true]
|
||||
* @returns {DomainListRepr | string} AST domain if 'raw', else the evaluated list domain
|
||||
* @returns {DomainListRepr | Domain} Domain instance if 'raw', else the evaluated list domain
|
||||
*/
|
||||
_getDomain(params = {}) {
|
||||
const withSearchPanel = "withSearchPanel" in params ? params.withSearchPanel : true;
|
||||
@@ -1755,7 +1755,7 @@ export class SearchModel extends EventBus {
|
||||
delete context[key];
|
||||
}
|
||||
}
|
||||
const rawDomain = this._getDomain({ raw: true, withGlobal: false });
|
||||
const domain = this._getDomain({ raw: true, withGlobal: false }).toString();
|
||||
const groupBys = this._getGroupBy();
|
||||
const comparison = this.getFullComparison();
|
||||
const orderBy = saveParams.orderBy ? saveParams.orderBy : this._getOrderBy() || [];
|
||||
@@ -1764,7 +1764,7 @@ export class SearchModel extends EventBus {
|
||||
const preFavorite = {
|
||||
description,
|
||||
isDefault,
|
||||
domain: rawDomain.toList(userContext),
|
||||
domain,
|
||||
context,
|
||||
groupBys,
|
||||
orderBy,
|
||||
@@ -1774,7 +1774,7 @@ export class SearchModel extends EventBus {
|
||||
name: description,
|
||||
action_id: this.action.id,
|
||||
model_id: this.resModel,
|
||||
domain: rawDomain.toString(),
|
||||
domain,
|
||||
is_default: isDefault,
|
||||
sort: JSON.stringify(orderBy.map((o) => `${o.name}${o.asc === false ? " desc" : ""}`)),
|
||||
user_id: userId,
|
||||
|
||||
@@ -2,9 +2,15 @@
|
||||
|
||||
import { legacyExtraNextTick } from "@web/../tests/helpers/utils";
|
||||
import {
|
||||
getFacetTexts, removeFacet, setupControlPanelServiceRegistry, switchView,
|
||||
getFacetTexts,
|
||||
removeFacet,
|
||||
saveFavorite,
|
||||
setupControlPanelServiceRegistry,
|
||||
switchView,
|
||||
toggleFavoriteMenu,
|
||||
toggleMenu,
|
||||
toggleMenuItem
|
||||
toggleMenuItem,
|
||||
toggleSaveFavorite,
|
||||
} from "@web/../tests/search/helpers";
|
||||
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
|
||||
import { dialogService } from "@web/core/dialog/dialog_service";
|
||||
@@ -244,6 +250,48 @@ QUnit.module("Views", (hooks) => {
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"newly created favorite in a new view can be used in a legacy view",
|
||||
async function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
const webClient = await createWebClient({
|
||||
serverData,
|
||||
mockRPC(_, args) {
|
||||
if (args.method === "create_or_replace") {
|
||||
assert.ok(typeof args.args[0].domain === "string");
|
||||
return 7; // fake serverId to simulate the creation of
|
||||
// the favorite in db.
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await doAction(webClient, {
|
||||
name: "Action name",
|
||||
res_model: "foo",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[false, "toy"],
|
||||
[false, "legacy_toy"],
|
||||
],
|
||||
});
|
||||
|
||||
assert.containsOnce(webClient, ".o_switch_view.o_toy.active");
|
||||
|
||||
await toggleFavoriteMenu(webClient);
|
||||
await toggleSaveFavorite(webClient);
|
||||
await saveFavorite(webClient);
|
||||
|
||||
assert.deepEqual(getFacetTexts(webClient), ["Action name"]);
|
||||
|
||||
await switchView(webClient, "legacy_toy");
|
||||
await legacyExtraNextTick();
|
||||
|
||||
assert.containsOnce(webClient, ".o_switch_view.o_legacy_toy.active");
|
||||
assert.deepEqual(getFacetTexts(webClient), ["Action name"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"legacy and new views with search model extensions can share search model state",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user