Skip to content

Commit

Permalink
fix: set_query filter for
Browse files Browse the repository at this point in the history
1. Custom_field
2. Customization
dt
  • Loading branch information
IamSaiyyamChhetri authored and IamSaiyyamChhetri committed Nov 6, 2024
1 parent 5e5c76c commit 1a3afcd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 7 additions & 2 deletions frappe/custom/doctype/custom_field/custom_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ frappe.ui.form.on("Custom Field", {
var filters = [
["DocType", "issingle", "=", 0],
["DocType", "custom", "=", 0],
["DocType", "name", "not in", frappe.model.core_doctypes_list],
["DocType", "restrict_to_domain", "in", frappe.boot.active_domains],
["DocType", "name", "not in", frappe.model.core_doctypes_list]

];

if (Array.isArray(frappe.boot.active_domains) && frappe.boot.active_domains.some(domain => domain)) {
filters.push(["DocType", "restrict_to_domain", "in", frappe.boot.active_domains]);
}

if (frappe.session.user !== "Administrator") {
filters.push(["DocType", "module", "not in", ["Core", "Custom"]]);
}
Expand Down
15 changes: 9 additions & 6 deletions frappe/custom/doctype/customize_form/customize_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ frappe.ui.form.on("Customize Form", {

onload: function (frm) {
frm.set_query("doc_type", function () {
let filters = [
["DocType", "issingle", "=", 0],
["DocType", "custom", "=", 0],
["DocType", "name", "not in", frappe.model.core_doctypes_list]
]
if (Array.isArray(frappe.boot.active_domains) && frappe.boot.active_domains.some(domain => domain)) {
filters.push(["DocType", "restrict_to_domain", "in", frappe.boot.active_domains]);
}
return {
filters: [
["DocType", "issingle", "=", 0],
["DocType", "custom", "=", 0],
["DocType", "name", "not in", frappe.model.core_doctypes_list],
["DocType", "restrict_to_domain", "in", frappe.boot.active_domains],
],
filters: filters,
};
});

Expand Down

0 comments on commit 1a3afcd

Please sign in to comment.