diff --git a/advanced_search_widget/README.rst b/advanced_search_widget/README.rst new file mode 100644 index 000000000..28e61070c --- /dev/null +++ b/advanced_search_widget/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Advanced Search Widget +==================== + +This module defines advanced search menu design and custom filter item expression. + +Configuration +============= +No additional configuration required + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +GNU Affero General Public License v3.0 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +Developer: (V16) Raneesha M K , Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if +your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/advanced_search_widget/__init__.py b/advanced_search_widget/__init__.py new file mode 100644 index 000000000..cba13a29c --- /dev/null +++ b/advanced_search_widget/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Raneesha M K (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### diff --git a/advanced_search_widget/__manifest__.py b/advanced_search_widget/__manifest__.py new file mode 100644 index 000000000..3d96e2b54 --- /dev/null +++ b/advanced_search_widget/__manifest__.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Raneesha M K (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': 'Advanced Search Widget', + 'version': '16.0.1.0.0', + 'category': 'Extra Tools', + 'summary': "It elevates the design of search menu items and offers" + "sophisticated expression options for filtering categories", + 'description': "An Advanced Search Widget could be custom widget designed" + "to enhance the search capabilities. It might offer more" + "advanced filtering options and search criteria.", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['web'], + 'assets': { + 'web.assets_backend': [ + 'advanced_search_widget/static/src/js/domain_tree.js', + 'advanced_search_widget/static/src/js/domain_selector_dialog.js', + 'advanced_search_widget/static/src/js/SearchWidget.js', + 'advanced_search_widget/static/src/js/search_bar.js', + 'advanced_search_widget/static/src/js/search_model.js', + 'advanced_search_widget/static/src/xml/custom_favorite_item.xml', + 'advanced_search_widget/static/src/xml/custom_filter_item.xml', + 'advanced_search_widget/static/src/xml/SearchWidget.xml', + 'advanced_search_widget/static/src/xml/search_bar.xml', + ], + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/advanced_search_widget/doc/RELEASE_NOTES.md b/advanced_search_widget/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..a4adaa320 --- /dev/null +++ b/advanced_search_widget/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 27.09.2023 +#### Version 16.0.1.0.0 +#### ADD +Initial Commit for Advanced Search Widget diff --git a/advanced_search_widget/static/description/assets/icons/check.png b/advanced_search_widget/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/check.png differ diff --git a/advanced_search_widget/static/description/assets/icons/chevron.png b/advanced_search_widget/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/chevron.png differ diff --git a/advanced_search_widget/static/description/assets/icons/cogs.png b/advanced_search_widget/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/cogs.png differ diff --git a/advanced_search_widget/static/description/assets/icons/consultation.png b/advanced_search_widget/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/consultation.png differ diff --git a/advanced_search_widget/static/description/assets/icons/ecom-black.png b/advanced_search_widget/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/ecom-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/education-black.png b/advanced_search_widget/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/education-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/hotel-black.png b/advanced_search_widget/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/hotel-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/license.png b/advanced_search_widget/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/license.png differ diff --git a/advanced_search_widget/static/description/assets/icons/lifebuoy.png b/advanced_search_widget/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/lifebuoy.png differ diff --git a/advanced_search_widget/static/description/assets/icons/manufacturing-black.png b/advanced_search_widget/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/manufacturing-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/pos-black.png b/advanced_search_widget/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/pos-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/puzzle.png b/advanced_search_widget/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/puzzle.png differ diff --git a/advanced_search_widget/static/description/assets/icons/restaurant-black.png b/advanced_search_widget/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/restaurant-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/service-black.png b/advanced_search_widget/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/service-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/trading-black.png b/advanced_search_widget/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/trading-black.png differ diff --git a/advanced_search_widget/static/description/assets/icons/training.png b/advanced_search_widget/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/training.png differ diff --git a/advanced_search_widget/static/description/assets/icons/update.png b/advanced_search_widget/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/update.png differ diff --git a/advanced_search_widget/static/description/assets/icons/user.png b/advanced_search_widget/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/user.png differ diff --git a/advanced_search_widget/static/description/assets/icons/wrench.png b/advanced_search_widget/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/advanced_search_widget/static/description/assets/icons/wrench.png differ diff --git a/advanced_search_widget/static/description/assets/misc/categories.png b/advanced_search_widget/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/categories.png differ diff --git a/advanced_search_widget/static/description/assets/misc/check-box.png b/advanced_search_widget/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/check-box.png differ diff --git a/advanced_search_widget/static/description/assets/misc/compass.png b/advanced_search_widget/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/compass.png differ diff --git a/advanced_search_widget/static/description/assets/misc/corporate.png b/advanced_search_widget/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/corporate.png differ diff --git a/advanced_search_widget/static/description/assets/misc/customer-support.png b/advanced_search_widget/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/customer-support.png differ diff --git a/advanced_search_widget/static/description/assets/misc/cybrosys-logo.png b/advanced_search_widget/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/cybrosys-logo.png differ diff --git a/advanced_search_widget/static/description/assets/misc/features.png b/advanced_search_widget/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/features.png differ diff --git a/advanced_search_widget/static/description/assets/misc/logo.png b/advanced_search_widget/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/logo.png differ diff --git a/advanced_search_widget/static/description/assets/misc/pictures.png b/advanced_search_widget/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/pictures.png differ diff --git a/advanced_search_widget/static/description/assets/misc/pie-chart.png b/advanced_search_widget/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/pie-chart.png differ diff --git a/advanced_search_widget/static/description/assets/misc/right-arrow.png b/advanced_search_widget/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/right-arrow.png differ diff --git a/advanced_search_widget/static/description/assets/misc/star.png b/advanced_search_widget/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/star.png differ diff --git a/advanced_search_widget/static/description/assets/misc/support.png b/advanced_search_widget/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/support.png differ diff --git a/advanced_search_widget/static/description/assets/misc/whatsapp.png b/advanced_search_widget/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/advanced_search_widget/static/description/assets/misc/whatsapp.png differ diff --git a/advanced_search_widget/static/description/assets/modules/1.png b/advanced_search_widget/static/description/assets/modules/1.png new file mode 100644 index 000000000..b21837312 Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/1.png differ diff --git a/advanced_search_widget/static/description/assets/modules/2.png b/advanced_search_widget/static/description/assets/modules/2.png new file mode 100644 index 000000000..eb3f8652f Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/2.png differ diff --git a/advanced_search_widget/static/description/assets/modules/3.png b/advanced_search_widget/static/description/assets/modules/3.png new file mode 100644 index 000000000..a9c4ec82c Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/3.png differ diff --git a/advanced_search_widget/static/description/assets/modules/4.png b/advanced_search_widget/static/description/assets/modules/4.png new file mode 100644 index 000000000..17ba4d75f Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/4.png differ diff --git a/advanced_search_widget/static/description/assets/modules/5.png b/advanced_search_widget/static/description/assets/modules/5.png new file mode 100644 index 000000000..489f44e86 Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/5.png differ diff --git a/advanced_search_widget/static/description/assets/modules/6.png b/advanced_search_widget/static/description/assets/modules/6.png new file mode 100644 index 000000000..ed11bd818 Binary files /dev/null and b/advanced_search_widget/static/description/assets/modules/6.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/1.png b/advanced_search_widget/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..501e0839a Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/1.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/2.png b/advanced_search_widget/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..4da1fc6c4 Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/2.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/3.png b/advanced_search_widget/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..d02fe217c Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/3.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/4.png b/advanced_search_widget/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..f035c5880 Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/4.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/5.png b/advanced_search_widget/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..10a48ab2e Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/5.png differ diff --git a/advanced_search_widget/static/description/assets/screenshots/hero.gif b/advanced_search_widget/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..63d6bf403 Binary files /dev/null and b/advanced_search_widget/static/description/assets/screenshots/hero.gif differ diff --git a/advanced_search_widget/static/description/banner.png b/advanced_search_widget/static/description/banner.png new file mode 100644 index 000000000..7a83fc15f Binary files /dev/null and b/advanced_search_widget/static/description/banner.png differ diff --git a/advanced_search_widget/static/description/cybro_logo.png b/advanced_search_widget/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/advanced_search_widget/static/description/cybro_logo.png differ diff --git a/advanced_search_widget/static/description/icon.png b/advanced_search_widget/static/description/icon.png new file mode 100644 index 000000000..1e73b083a Binary files /dev/null and b/advanced_search_widget/static/description/icon.png differ diff --git a/advanced_search_widget/static/description/index.html b/advanced_search_widget/static/description/index.html new file mode 100644 index 000000000..cf39cccea --- /dev/null +++ b/advanced_search_widget/static/description/index.html @@ -0,0 +1,640 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ + + +
+
+
+

+ Advanced Search Widget

+

+ An Advanced Design of Search Menu Items and Advanced + Expression for Category Filter Options

+
+
+
+ + +
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ Here, we show an advanced view of the search menus, including the + filter, group by, and favourites options. For adding unique filters, it + defines advanced expressions. The user-friendly design also includes + options to save favourites and group by customers. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Search Menus are in single dropdown. +
+
+ + Advanced expressions are available for custom filter choices. +
+
+ + Search menus with a user-friendly interface +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+
+

The dropdown arrow symbol allows you to view the search menus in more detail.

+ +
+ +
+

+ Advanced Custom Filter view

+

By selecting "Add Custom Filter", you can get an enhanced view with branch and node criteria. The ' + ' button allows you to add numerous nodes.

+ +
+ +
+

Branch condition of Custom Filter

+

The new capability or requirement is that we can now add a single filter with two conditions.

+ +
+ +
+

+ Add Custom Group

+

Added a wizard window for the opportunity to add a custom group.

+ +
+ +
+

+ Save current search feature of Favorites menu

+

+ Added a wizard window for the opportunity to save current search feature.

+ +
+ +
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + + +
+
+ +
+

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+ +
+ + + + +
+
+ +
+

+ Our + Industries +

+
+ +
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/advanced_search_widget/static/src/js/SearchWidget.js b/advanced_search_widget/static/src/js/SearchWidget.js new file mode 100644 index 000000000..7eea2b958 --- /dev/null +++ b/advanced_search_widget/static/src/js/SearchWidget.js @@ -0,0 +1,135 @@ +/** @odoo-module **/ + +import { Dropdown } from "@web/core/dropdown/dropdown"; +import { registry } from "@web/core/registry"; +import { useBus, useService } from "@web/core/utils/hooks"; +import { Component } from "@odoo/owl"; +import { SearchDropdownItem } from "@web/search/search_dropdown_item/search_dropdown_item"; +import { CustomGroupByItem } from "@web/search/group_by_menu/custom_group_by_item"; +import { FACET_ICONS, GROUPABLE_TYPES } from "@web/search/utils/misc"; +import { sortBy } from "@web/core/utils/arrays"; +import { DropdownItem } from "@web/core/dropdown/dropdown_item"; +import { _t } from "@web/core/l10n/translation"; +import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; +import { DomainSelectorDialog } from "@web/core/domain_selector_dialog/domain_selector_dialog"; +const favoriteMenuRegistry = registry.category("favoriteMenu"); + +export class SearchWidget extends Component { + setup() { + // Filter + this.dialogService = useService("dialog"); + this.filterIcon = FACET_ICONS.filter; + // GroupBy + const fields = []; + for (const [fieldName, field] of Object.entries(this.env.searchModel.searchViewFields)) { + if (this.validateField(fieldName, field)) { + fields.push(Object.assign({ name: fieldName }, field)); + } + } + this.groupByIcon = FACET_ICONS.groupBy; + this.fields = sortBy(fields, "string"); + // Favorite + this.favoriteIcon = FACET_ICONS.favorite; + useBus(this.env.searchModel, "update", this.render); + } + +// Filter Menu + get Filteritems() { + // Get filter items for the menu. + return this.env.searchModel.getSearchItems((searchItem) => + ["filter", "dateFilter"].includes(searchItem.type) + ); + } + onFilterSelected({ itemId, optionId }) { + // Handle selection of a filter item. + if (optionId) { + this.env.searchModel.toggleDateFilter(itemId, optionId); + } else { + this.env.searchModel.toggleSearchItem(itemId); + } + } +// Add custom filter dialog + onAddCustomFilterClick() { + const { _context: context, resModel } = this.env.searchModel; + this.dialogService.add(DomainSelectorDialog, { + resModel, + domain : "[]", + context, + readonly : false, + title: _t("Add Custom Filter"), + onSave: (domain) => this.env.searchModel.splitAndAddDomain(domain), + isDebugMode: !!this.env.debug, + }) + } + +// GroupBy Menu + get groupByitems() { + // Get groupBy items for the menu. + return this.env.searchModel.getSearchItems((searchItem) => + ["groupBy", "dateGroupBy"].includes(searchItem.type) + ); + } + onGroupBySelected({ itemId, optionId }) { + // Handle selection of a groupBy item. + if (optionId) { + this.env.searchModel.toggleDateGroupBy(itemId, optionId); + } else { + this.env.searchModel.toggleSearchItem(itemId); + } + } + onAddCustomGroup(fieldName) { + // Create new custom group by + this.env.searchModel.createNewGroupBy(fieldName); + } + get hideCustomGroupBy() { + // Hide new custom group by + return this.env.searchModel.hideCustomGroupBy || false; + } + validateField(fieldName, field) { + // Validate if a field is suitable for groupBy + const { sortable, store, type } = field; + return ( + (type === "many2many" ? store : sortable) && + fieldName !== "id" && + GROUPABLE_TYPES.includes(type) + ); + } +// Favorite Menu + get favoriteitems() { + // Get favorite items for the menu. + const favorites = this.env.searchModel.getSearchItems( + (searchItem) => searchItem.type === "favorite" + ); + const registryMenus = []; + for (const item of favoriteMenuRegistry.getAll()) { + if ("isDisplayed" in item ? item.isDisplayed(this.env) : true) { + registryMenus.push({ + Component: item.Component, + groupNumber: item.groupNumber, + key: item.Component.name, + }); + } + } + return [...favorites, ...registryMenus]; + } + onFavoriteSelected(itemId) { + this.env.searchModel.toggleSearchItem(itemId); + } + openConfirmationDialog(itemId) { + // Open a confirmation dialog for removing a favorite item. + const { userId } = this.favoriteitems.find((item) => item.id === itemId); + const dialogProps = { + title: this.env._t("Warning"), + body: userId + ? this.env._t("Are you sure that you want to remove this filter?") + : this.env._t( + "This filter is global and will be removed for everybody if you continue." + ), + confirm: () => this.env.searchModel.deleteFavorite(itemId), + cancel: () => {}, + }; + this.dialogService.add(ConfirmationDialog, dialogProps); + } +} +SearchWidget.template = "SearchWidget"; +SearchWidget.components = {Dropdown, CustomGroupByItem, DropdownItem:SearchDropdownItem}; diff --git a/advanced_search_widget/static/src/js/domain_selector_dialog.js b/advanced_search_widget/static/src/js/domain_selector_dialog.js new file mode 100644 index 000000000..3dd92c378 --- /dev/null +++ b/advanced_search_widget/static/src/js/domain_selector_dialog.js @@ -0,0 +1,58 @@ +/** @odoo-module **/ +/** + * This file is used to add some features to DomainSelectorDialog . +*/ +import { DomainSelectorDialog } from "@web/core/domain_selector_dialog/domain_selector_dialog"; +import {useService } from "@web/core/utils/hooks"; +import { useState } from "@odoo/owl"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; +import { Domain } from "@web/core/domain"; + +patch(DomainSelectorDialog.prototype, 'advanced_search_widget', { + setup() { + this.orm = useService("orm"); + this.notification = useService("notification"); + this.state = useState({ + domain: this.props.domain + }); + return this._super(...arguments); + }, + get dialogTitle() { + // Return title of the DomainSelectorDialog + return this.props.title || _t("Domain"); + }, + get domainSelectorProps() { + // Default domain selector props values + return { + className: this.props.className, + resModel: this.props.resModel, + readonly: this.props.readonly, + isDebugMode: this.props.isDebugMode, + defaultLeafValue: this.props.defaultLeafValue, + value: this.state.domain || this.props.domain, + update: (domain) => { + this.state.domain = domain; + }, + }; + }, + async onSave() { + // It will apply the domain as new filter + if (!this.state.domain){ + this.notification.add(this.env._t("Domain is invalid. Please correct it"), { + type: "danger", + }); + } + else{ + this.props.onSave(this.state.domain); + this.props.close(); + } + }, +}); +DomainSelectorDialog.props = { + ...DomainSelectorDialog.props, + onSave: Function, + title: { type: String, optional: true }, + context: { type: Object, optional: true }, + domain: { type: String, optional: true }, +}; diff --git a/advanced_search_widget/static/src/js/domain_tree.js b/advanced_search_widget/static/src/js/domain_tree.js new file mode 100644 index 000000000..6e1f310f1 --- /dev/null +++ b/advanced_search_widget/static/src/js/domain_tree.js @@ -0,0 +1,159 @@ +/** @odoo-module **/ +/** + * This file is used to create the domain as tree structure based on the + branch and node domains and also based on the operator. +*/ +import { Domain } from "@web/core/domain"; +import { formatAST, toPyValue} from "@web/core/py_js/py_utils"; +const TERM_OPERATORS_NEGATION = { + "<": ">=", + ">": "<=", + "<=": ">", + ">=": "<", + "=": "!=", + "!=": "=", + in: "not in", + like: "not like", + ilike: "not ilike", + "not in": "in", + "not like": "like", + "not ilike": "ilike", +}; + +function _construcTree(ASTs, distributeNot, negate = false) { + // Construct a tree structure based on the branch and node domains and the operator. + const [firstAST, ...tailASTs] = ASTs; + + if (firstAST.type === 1 && firstAST.value === "!") { + return _construcTree(tailASTs, distributeNot, !negate); + } + + const tree = { + type: firstAST.type === 1 ? "connector" : "condition" + }; + if (tree.type === "connector") { + tree.value = firstAST.value; + if (distributeNot && negate) { + tree.value = tree.value === "&" ? "|" : "&"; + tree.negate = false; + } else { + tree.negate = negate; + } + tree.children = []; + } else { + const [pathAST, operatorAST, valueAST] = firstAST.value; + tree.path = pathAST.value; + if (negate && TERM_OPERATORS_NEGATION[operatorAST.value]) { + tree.operator = TERM_OPERATORS_NEGATION[operatorAST.value]; + } else { + tree.operator = operatorAST.value; + tree.negate = negate; + } + tree.valueAST = valueAST; + } + let remaimingASTs = tailASTs; + if (tree.type === "connector") { + for (let i = 0; i < 2; i++) { + const { + tree: child, + remaimingASTs: otherASTs + } = _construcTree( + remaimingASTs, + distributeNot, + distributeNot && negate + ); + remaimingASTs = otherASTs; + if (child.type === "connector" && !child.negate && child.value === tree.value) { + tree.children.push(...child.children); + } else { + tree.children.push(child); + } + } + } + return { + tree, + remaimingASTs + }; +} + +function construcTree(initialASTs, options) { + // Construct a tree structure based on the initial abstract syntax trees and options + const value = options.defaultConnector || "&"; + if (!initialASTs.length) { + return { + type: "connector", + value, + negate: false, + children: [] + }; + } + const { + tree + } = _construcTree(initialASTs, options.distributeNot); + if (tree.type === "condition") { + return { + type: "connector", + value, + negate: false, + children: [tree] + }; + } + return tree; +} + +function createBetweenOperators(tree, isRoot = true) { + // Create between operators from a tree structure representing the domain. + if (tree.type === "condition") { + return tree; + } + const processedChildren = tree.children.map((c) => createBetweenOperators(c, false)); + if (tree.value === "|") { + return { + ...tree, + children: processedChildren + }; + } + const children = []; + for (let i = 0; i < processedChildren.length; i++) { + const child1 = processedChildren[i]; + const child2 = processedChildren[i + 1]; + if ( + child1.type === "condition" && + child2 && + child2.type === "condition" && + child1.path === child2.path && + child1.operator === ">=" && + child2.operator === "<=" + ) { + children.push({ + type: "condition", + path: child1.path, + operator: "between", + valueAST: { + type: 4, + value: [child1.valueAST, child2.valueAST], + }, + }); + i += 1; + } else { + children.push(child1); + } + } + if (children.length === 1 && !isRoot) { + return { + ...children[0] + }; + } + return { + ...tree, + children + }; +} + +export function toTree(domain, options = {}) { + // Convert a domain to a tree structure. + domain = new Domain(domain); + const domainAST = domain.ast; + const tree = construcTree(domainAST.value, options); + return createBetweenOperators(tree); +} diff --git a/advanced_search_widget/static/src/js/search_bar.js b/advanced_search_widget/static/src/js/search_bar.js new file mode 100644 index 000000000..ee006ae0f --- /dev/null +++ b/advanced_search_widget/static/src/js/search_bar.js @@ -0,0 +1,10 @@ +/** @odoo-module **/ +/** + * This file is used to add the SearchWidget component SearchBar . +*/ +import { SearchBar } from "@web/search/search_bar/search_bar"; +import {SearchWidget} from "@advanced_search_widget/js/SearchWidget"; + +SearchBar.components = { + SearchWidget, +}; diff --git a/advanced_search_widget/static/src/js/search_model.js b/advanced_search_widget/static/src/js/search_model.js new file mode 100644 index 000000000..455b2dd04 --- /dev/null +++ b/advanced_search_widget/static/src/js/search_model.js @@ -0,0 +1,81 @@ +/** @odoo-module **/ +/** + * This file is used to add a some functions to SearchModel for creating filter . + */ +import { SearchModel} from "@web/search/search_model"; +import {patch} from "@web/core/utils/patch"; +import {toTree} from "@advanced_search_widget/js/domain_tree" + +patch(SearchModel.prototype, 'advanced_search_widget', { + setup() { + return this._super(...arguments); + }, + FieldType(tree, description) { + // Return a description of the domain operator string based on the operator + if (tree.valueAST.type === 2) { + description += ' is'; + if (tree.operator === '=' && !tree.valueAST.value) { + description += ' not'; + } + if (tree.operator === '!=' && tree.valueAST.value) { + description += ' not'; + } + description += ' set'; + } else if (tree.valueAST.type === 1) { + if (tree.operator === 'ilike') { + description += ' contains ' + tree.valueAST.value; + } else if (tree.operator === 'not ilike') { + description += ' does not contain ' + tree.valueAST.value; + } else { + description += ' ' + tree.operator + ' ' + tree.valueAST.value; + } + } else if (tree.valueAST.type === 0) { + description += ' ' + tree.operator + ' ' + tree.valueAST.value; + } + return description; + }, + + DomainDescription(tree) { + // Returns a description for the domain to show in the search bar. + const getFieldString = (path) => { + if (path.includes(".")) { + const [mainField, subField] = path.split("."); + return `${this.searchViewFields[mainField].string} ${this.searchViewFields[subField].string}`; + } else { + return this.searchViewFields[path].string; + } + }; + let description; + switch (tree.type) { + case 'condition': + description = this.FieldType(tree, getFieldString(tree.path)); + break; + case 'connector': + const childDescriptions = tree.children.map((childTree) => + this.FieldType(childTree, getFieldString(childTree.path))); + description = childDescriptions.join(" or "); + break; + } + return description; + }, + + async splitAndAddDomain(domain) { + // It will split domain based domain is branch or node and create filters + const tree = toTree(domain); + const trees = !tree.negate && tree.value === "&" ? tree.children : [tree]; + const promises = trees.map(async (tree) => { + const description = await this.DomainDescription(tree); + const preFilter = { + description, + domain: domain, + invisible: true, + type: "filter", + }; + return preFilter; + }); + const preFilters = await Promise.all(promises); + for (const preFilter of preFilters) { + this.createNewFilters([preFilter]); + } + } +}); diff --git a/advanced_search_widget/static/src/xml/SearchWidget.xml b/advanced_search_widget/static/src/xml/SearchWidget.xml new file mode 100644 index 000000000..9fb4a1c18 --- /dev/null +++ b/advanced_search_widget/static/src/xml/SearchWidget.xml @@ -0,0 +1,160 @@ + + + + + + + + + + +
+
+ +
Filters
+
+ + + +