I am trying to fetch the parent cost center but it shows the same values as cost center in the filter:
The parent cost centers are only 3 but it shows the same values as cost center here:
I am trying to fetch the parent cost center but it shows the same values as cost center in the filter:
The parent cost centers are only 3 but it shows the same values as cost center here:
This is the .js file:
frappe.query_reports[“Sales Expense Breakup Item Wise”] = {
“filters”: [
{
fieldname: “from_date”,
label: __(“From Date”),
fieldtype: “Date”,
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
reqd: 1,
},
{
fieldname: “to_date”,
label: __(“To Date”),
fieldtype: “Date”,
default: frappe.datetime.get_today(),
reqd: 1,
},
{
fieldname: “item_code”,
label: __(“Item”),
fieldtype: “Link”,
options: “Item”,
},
{
fieldname: “cost_center_name”,
label: __(“Cost Center”),
fieldtype: “Link”,
options: “Cost Center”,
},
{
fieldname: “parent_cost_center”,
label: __(“Cost Center Parent”),
fieldtype: “Link”,
options: “Cost Center”,
},
{
fieldname: “territory_name”,
label: __(“Territory”),
fieldtype: “Link”,
options: “Territory”,
},
{
fieldname: “parent_territory”,
label: __(“Territory Parent”),
fieldtype: “Link”,
options: “Territory”,
},
],
formatter: function (value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (data && data.bold) {
value = value.bold();
}
return value;
},
};
@Hamza3351 Try this code :
frappe.query_reports[“Sales Expense Breakup Item Wise”] = {
“filters”: [
{
fieldname: “from_date”,
label: __(“From Date”),
fieldtype: “Date”,
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
reqd: 1,
},
{
fieldname: “to_date”,
label: __(“To Date”),
fieldtype: “Date”,
default: frappe.datetime.get_today(),
reqd: 1,
},
{
fieldname: “item_code”,
label: __(“Item”),
fieldtype: “Link”,
options: “Item”,
},
{
fieldname: “cost_center_name”,
label: __(“Cost Center”),
fieldtype: “Link”,
options: “Cost Center”,
},
{
fieldname: “parent_cost_center”,
label: __(“Cost Center Parent”),
fieldtype: “Link”,
options: “Cost Center”,
“get_query”: function() {
return {
filters: {
“is_group”: 1
}
};
}
},
{
fieldname: “territory_name”,
label: __(“Territory”),
fieldtype: “Link”,
options: “Territory”,
},
{
fieldname: “parent_territory”,
label: __(“Territory Parent”),
fieldtype: “Link”,
options: “Territory”,
},
],
formatter: function (value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (data && data.bold) {
value = value.bold();
}
return value;
},
};
Hi @Hamza3351,
update your code.
{
"fieldname": "parent_cost_center",
"label": __("Parent Cost Center"),
"fieldtype": "Link",
"options": "Cost Center",
"get_query": function() {
return {
filters: {
"is_group": 1
}
};
}
},
{
"fieldname": "parent_territory",
"label": __("Parent Territory"),
"fieldtype": "Link",
"options": "Territory",
"get_query": function() {
return {
filters: {
"is_group": 1
}
};
}
},