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:
rohitwaghchaure 2023-01-16 23:57:43 +05:30 committed by GitHub
commit 66ae807a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 24 deletions

View File

@ -13,38 +13,24 @@ frappe.query_reports["Work Order Summary"] = {
reqd: 1
},
{
fieldname: "fiscal_year",
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.defaults.get_user_default("fiscal_year"),
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: __("Based On"),
fieldname:"based_on",
fieldtype: "Select",
options: "Creation Date\nPlanned Date\nActual Date",
default: "Creation Date"
},
{
label: __("From Posting Date"),
fieldname:"from_date",
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: frappe.datetime.add_months(frappe.datetime.get_today(), -3),
reqd: 1
},
{
label: __("To Posting Date"),
fieldname:"to_date",
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: frappe.datetime.get_today(),
reqd: 1,
},
{

View File

@ -31,6 +31,7 @@ def get_data(filters):
"sales_order",
"production_item",
"qty",
"creation",
"produced_qty",
"planned_start_date",
"planned_end_date",
@ -47,11 +48,17 @@ def get_data(filters):
if filters.get(field):
query_filters[field] = filters.get(field)
query_filters["planned_start_date"] = (">=", filters.get("from_date"))
query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
if filters.get("based_on") == "Planned Date":
query_filters["planned_start_date"] = (">=", filters.get("from_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(
"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 = []
@ -213,6 +220,12 @@ def get_columns(filters):
"options": "Sales Order",
"width": 90,
},
{
"label": _("Created On"),
"fieldname": "creation",
"fieldtype": "Date",
"width": 150,
},
{
"label": _("Planned Start Date"),
"fieldname": "planned_start_date",