diff --git a/schemas/core/SystemSettings.json b/schemas/core/SystemSettings.json
index 39a376016..f55ca4f4f 100644
--- a/schemas/core/SystemSettings.json
+++ b/schemas/core/SystemSettings.json
@@ -64,6 +64,14 @@
"readOnly": true,
"section": "Default"
},
+ {
+ "fieldname": "allowFilterBypass",
+ "label": "Allow to bypass filters",
+ "fieldtype": "Check",
+ "default": false,
+ "description": "When linking documents, if no match is found and filtering is in effect, allow to disable filters.",
+ "section": "Default"
+ },
{
"fieldname": "locale",
"label": "Locale",
diff --git a/src/components/Controls/Link.vue b/src/components/Controls/Link.vue
index fe48501ce..99af4af5b 100644
--- a/src/components/Controls/Link.vue
+++ b/src/components/Controls/Link.vue
@@ -11,7 +11,7 @@ export default {
name: 'Link',
extends: AutoComplete,
data() {
- return { results: [] };
+ return { results: [], filtersDisabled: false };
},
watch: {
value: {
@@ -45,7 +45,7 @@ export default {
getTargetSchemaName() {
return this.df.target;
},
- async getOptions() {
+ async getOptions(filters) {
const schemaName = this.getTargetSchemaName();
if (!schemaName) {
return [];
@@ -56,7 +56,6 @@ export default {
}
const schema = fyo.schemaMap[schemaName];
- const filters = await this.getFilters();
const fields = [
...new Set(['name', schema.titleField, this.df.groupBy]),
@@ -78,7 +77,8 @@ export default {
.filter(Boolean));
},
async getSuggestions(keyword = '') {
- let options = await this.getOptions();
+ let filters = this.filtersDisabled ? null : await this.getFilters();
+ let options = await this.getOptions(filters || {});
if (keyword) {
options = options
@@ -88,21 +88,34 @@ export default {
.map(({ item }) => item);
}
- if (this.doc && this.df.create) {
- options = options.concat(this.getCreateNewOption());
+ if (options.length === 0 && !this.df.emptyMessage) {
+ if (filters && !!fyo.singles.SystemSettings?.allowFilterBypass) {
+ options = [
+ {
+ component: markRaw({
+ template:
+ '{{ t`No results found, disable filters` }}',
+ }),
+ action: () => this.disableFiltering(),
+ actionOnly: true,
+ },
+ ];
+ } else if (!this.doc || !this.df.create) {
+ options = [
+ {
+ component: markRaw({
+ template:
+ '{{ t`No results found` }}',
+ }),
+ action: () => {},
+ actionOnly: true,
+ },
+ ];
+ }
}
- if (options.length === 0 && !this.df.emptyMessage) {
- return [
- {
- component: markRaw({
- template:
- '{{ t`No results found` }}',
- }),
- action: () => {},
- actionOnly: true,
- },
- ];
+ if (this.doc && this.df.create) {
+ options = options.concat(this.getCreateNewOption());
}
return options;
@@ -129,6 +142,14 @@ export default {
}),
};
},
+ disableFiltering(keyword) {
+ this.filtersDisabled = true;
+ this.results = [];
+ setTimeout(() => {
+ this.toggleDropdown(true);
+ this.updateSuggestions(keyword);
+ }, 1);
+ },
async openNewDoc() {
const schemaName = this.df.target;
const name =
@@ -155,7 +176,7 @@ export default {
return createFilters;
}
- const filters = await this.getFilters();
+ const filters = (await this.getFilters()) ?? {};
return getCreateFiltersFromListViewFilters(filters);
},
async getFilters() {
@@ -163,17 +184,17 @@ export default {
const getFilters = fyo.models[schemaName]?.filters?.[fieldname];
if (getFilters === undefined) {
- return {};
+ return null;
}
if (this.doc) {
- return (await getFilters(this.doc)) ?? {};
+ return await getFilters(this.doc);
}
try {
- return (await getFilters()) ?? {};
+ return await getFilters();
} catch {
- return {};
+ return null;
}
},
},
diff --git a/translations/fr.csv b/translations/fr.csv
index a31c5993a..37d07a0b6 100644
--- a/translations/fr.csv
+++ b/translations/fr.csv
@@ -572,6 +572,7 @@ No,Non,
"No filters selected","Aucun filtre sélectionné",
"No linked entries found",,
"No results found","Aucun résultat trouvé",
+"No results found, disable filters","Aucun résultat trouvé, désactiver les filtres",
"No rows added. Select a file or add rows.",,
"No transactions yet","Aucune transaction pour le moment",
"Non Active Serial Number ${0} cannot be used as Manufacture raw material",,
@@ -1055,4 +1056,6 @@ Yes,Oui,
"check values and click on","Vérifiez les valeurs et cliquez sur",
"in Batch ${0}",,
john@doe.com,,
-"to apply changes","pour appliquer les changements",
\ No newline at end of file
+"to apply changes","pour appliquer les changements",
+"Allow to bypass filters","Autoriser la désactivation des filtres"
+"When linking documents, if no match is found and filtering is in effect, allow to disable filters.","Lors de la sélection d'un document lié, autoriser à désactiver les filtres si aucun résultat n'est trouvé"