Browse Source

Dec 8 : [FIX] Bug Fixed 'advanced_search_widget'

pull/295/head
AjmalCybro 1 year ago
parent
commit
7836462c7a
  1. 2
      advanced_search_widget/__manifest__.py
  2. 2
      advanced_search_widget/doc/RELEASE_NOTES.md
  3. 30
      advanced_search_widget/static/src/js/search_model.js
  4. 0
      advanced_search_widget/static/src/xml/custom_groupby_item.xml

2
advanced_search_widget/__manifest__.py

@ -41,7 +41,7 @@
'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/custom_groupby_item.xml',
'advanced_search_widget/static/src/xml/SearchWidget.xml',
'advanced_search_widget/static/src/xml/search_bar.xml',
],

2
advanced_search_widget/doc/RELEASE_NOTES.md

@ -1,6 +1,6 @@
## Module <advanced_search_widget>
#### 27.09.2023
#### 28.11.2023
#### Version 16.0.1.0.0
#### ADD
Initial Commit for Advanced Search Widget

30
advanced_search_widget/static/src/js/search_model.js

@ -5,6 +5,7 @@
import { SearchModel} from "@web/search/search_model";
import {patch} from "@web/core/utils/patch";
import {toTree} from "@advanced_search_widget/js/domain_tree"
import rpc from 'web.rpc';
patch(SearchModel.prototype, 'advanced_search_widget', {
setup() {
@ -35,24 +36,41 @@ patch(SearchModel.prototype, 'advanced_search_widget', {
return description;
},
DomainDescription(tree) {
async DomainDescription(tree) {
// Returns a description for the domain to show in the search bar.
const getFieldString = (path) => {
const getFieldString = async (path) => {
if (path.includes(".")) {
const [mainField, subField] = path.split(".");
return `${this.searchViewFields[mainField].string} ${this.searchViewFields[subField].string}`;
var paths = path.split(".");
var mainField = paths[0];
var subFields = paths.slice(1);
var validTypes = ['one2many','many2one','many2many']
if(validTypes.includes(this.searchViewFields[mainField].type)){
var model = this.searchViewFields[mainField].relation;
var firstString = this.searchViewFields[mainField].string;
for (const subField of subFields) {
const result = await rpc.query({
model: model,
method: "fields_get",
args: [[subField]],
});
model = result[subField].relation;
firstString += ` > ${result[subField].string}`;
}
}
return firstString;
} else {
return this.searchViewFields[path].string;
}
};
let description;
let value;
switch (tree.type) {
case 'condition':
description = this.FieldType(tree, getFieldString(tree.path));
description = this.FieldType(tree, await Promise.resolve(getFieldString(tree.path)));
break;
case 'connector':
const childDescriptions = tree.children.map((childTree) =>
this.FieldType(childTree, getFieldString(childTree.path)));
this.FieldType(childTree, Promise.resolve(getFieldString(tree.path))));
description = childDescriptions.join(" or ");
break;
}

0
advanced_search_widget/static/src/xml/custom_filter_item.xml → advanced_search_widget/static/src/xml/custom_groupby_item.xml

Loading…
Cancel
Save