Merge pull request #33684 from rohitwaghchaure/fixed-work-order-summary
feat: [minor] date type based on filter in Work Order Summary report
This commit is contained in:
commit
66ae807a26
@ -13,38 +13,24 @@ frappe.query_reports["Work Order Summary"] = {
|
|||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "fiscal_year",
|
label: __("Based On"),
|
||||||
label: __("Fiscal Year"),
|
fieldname:"based_on",
|
||||||
fieldtype: "Link",
|
fieldtype: "Select",
|
||||||
options: "Fiscal Year",
|
options: "Creation Date\nPlanned Date\nActual Date",
|
||||||
default: frappe.defaults.get_user_default("fiscal_year"),
|
default: "Creation Date"
|
||||||
reqd: 1,
|
|
||||||
on_change: function(query_report) {
|
|
||||||
var fiscal_year = query_report.get_values().fiscal_year;
|
|
||||||
if (!fiscal_year) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
|
|
||||||
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
|
|
||||||
frappe.query_report.set_filter_value({
|
|
||||||
from_date: fy.year_start_date,
|
|
||||||
to_date: fy.year_end_date
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __("From Posting Date"),
|
label: __("From Posting Date"),
|
||||||
fieldname:"from_date",
|
fieldname:"from_date",
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.defaults.get_user_default("year_start_date"),
|
default: frappe.datetime.add_months(frappe.datetime.get_today(), -3),
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __("To Posting Date"),
|
label: __("To Posting Date"),
|
||||||
fieldname:"to_date",
|
fieldname:"to_date",
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: frappe.defaults.get_user_default("year_end_date"),
|
default: frappe.datetime.get_today(),
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,7 @@ def get_data(filters):
|
|||||||
"sales_order",
|
"sales_order",
|
||||||
"production_item",
|
"production_item",
|
||||||
"qty",
|
"qty",
|
||||||
|
"creation",
|
||||||
"produced_qty",
|
"produced_qty",
|
||||||
"planned_start_date",
|
"planned_start_date",
|
||||||
"planned_end_date",
|
"planned_end_date",
|
||||||
@ -47,11 +48,17 @@ def get_data(filters):
|
|||||||
if filters.get(field):
|
if filters.get(field):
|
||||||
query_filters[field] = filters.get(field)
|
query_filters[field] = filters.get(field)
|
||||||
|
|
||||||
|
if filters.get("based_on") == "Planned Date":
|
||||||
query_filters["planned_start_date"] = (">=", filters.get("from_date"))
|
query_filters["planned_start_date"] = (">=", filters.get("from_date"))
|
||||||
query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
|
query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
|
||||||
|
elif filters.get("based_on") == "Actual Date":
|
||||||
|
query_filters["actual_start_date"] = (">=", filters.get("from_date"))
|
||||||
|
query_filters["actual_end_date"] = ("<=", filters.get("to_date"))
|
||||||
|
else:
|
||||||
|
query_filters["creation"] = ("between", [filters.get("from_date"), filters.get("to_date")])
|
||||||
|
|
||||||
data = frappe.get_all(
|
data = frappe.get_all(
|
||||||
"Work Order", fields=fields, filters=query_filters, order_by="planned_start_date asc"
|
"Work Order", fields=fields, filters=query_filters, order_by="planned_start_date asc", debug=1
|
||||||
)
|
)
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
@ -213,6 +220,12 @@ def get_columns(filters):
|
|||||||
"options": "Sales Order",
|
"options": "Sales Order",
|
||||||
"width": 90,
|
"width": 90,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": _("Created On"),
|
||||||
|
"fieldname": "creation",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 150,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": _("Planned Start Date"),
|
"label": _("Planned Start Date"),
|
||||||
"fieldname": "planned_start_date",
|
"fieldname": "planned_start_date",
|
||||||
|
Loading…
Reference in New Issue
Block a user