diff --git a/addons/web/static/src/search/favorite_menu/favorite_menu.xml b/addons/web/static/src/search/favorite_menu/favorite_menu.xml
index f2ebcc6545a..ff15b986a16 100644
--- a/addons/web/static/src/search/favorite_menu/favorite_menu.xml
+++ b/addons/web/static/src/search/favorite_menu/favorite_menu.xml
@@ -8,7 +8,7 @@
Favorites
-
+
@@ -28,7 +28,7 @@
-
+
diff --git a/addons/web/static/src/search/search_model.js b/addons/web/static/src/search/search_model.js
index 7286c5dea09..9d9328a4600 100644
--- a/addons/web/static/src/search/search_model.js
+++ b/addons/web/static/src/search/search_model.js
@@ -154,10 +154,10 @@ const FAVORITE_PRIVATE_GROUP = 1;
const FAVORITE_SHARED_GROUP = 2;
export class SearchModel extends EventBus {
- constructor(env, services) {
+ constructor(env, services, args) {
super();
this.env = env;
- this.setup(services);
+ this.setup(services, args);
}
/**
* @override
@@ -593,8 +593,7 @@ export class SearchModel extends EventBus {
*/
async createNewFavorite(params) {
const { preFavorite, irFilter } = this._getIrFilterDescription(params);
- const serverSideId = await this.orm.call("ir.filters", "create_or_replace", [irFilter]);
- this.env.bus.trigger("CLEAR-CACHES");
+ const serverSideId = await this._createIrFilters(irFilter);
// before the filter cache was cleared!
this.blockNotification = true;
@@ -616,6 +615,12 @@ export class SearchModel extends EventBus {
this._notify();
}
+ async _createIrFilters(irFilter) {
+ const serverSideId = await this.orm.call("ir.filters", "create_or_replace", [irFilter]);
+ this.env.bus.trigger("CLEAR-CACHES");
+ return serverSideId;
+ }
+
/**
* Create new search items of type 'filter' and activate them.
* A new group containing only those filters is created.
@@ -702,9 +707,7 @@ export class SearchModel extends EventBus {
if (searchItem.type !== "favorite") {
return;
}
- const { serverSideId } = searchItem;
- await this.orm.unlink("ir.filters", [serverSideId]);
- this.env.bus.trigger("CLEAR-CACHES");
+ await this._deleteIrFilters(searchItem);
const index = this.query.findIndex((queryElem) => queryElem.searchItemId === favoriteId);
delete this.searchItems[favoriteId];
if (index >= 0) {
@@ -713,6 +716,12 @@ export class SearchModel extends EventBus {
this._notify();
}
+ async _deleteIrFilters(searchItem) {
+ const { serverSideId } = searchItem;
+ await this.orm.unlink("ir.filters", [serverSideId]);
+ this.env.bus.trigger("CLEAR-CACHES");
+ }
+
/**
* @returns {Object}
*/
diff --git a/addons/web/static/src/search/with_search/with_search.js b/addons/web/static/src/search/with_search/with_search.js
index 3c052bd2cf7..b7e939ced74 100644
--- a/addons/web/static/src/search/with_search/with_search.js
+++ b/addons/web/static/src/search/with_search/with_search.js
@@ -18,11 +18,15 @@ export class WithSearch extends Component {
}
const SearchModelClass = this.props.SearchModel || SearchModel;
- this.searchModel = new SearchModelClass(this.env, {
- user: useService("user"),
- orm: useService("orm"),
- view: useService("view"),
- });
+ this.searchModel = new SearchModelClass(
+ this.env,
+ {
+ user: useService("user"),
+ orm: useService("orm"),
+ view: useService("view"),
+ },
+ this.props.searchModelArgs
+ );
useSubEnv({ searchModel: this.searchModel });
@@ -64,6 +68,7 @@ WithSearch.props = {
resModel: String,
globalState: { type: Object, optional: true },
+ searchModelArgs: { type: Object, optional: true },
display: { type: Object, optional: true },