mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-27 05:45:19 +00:00
fix(Material Requirements Planning Report): detailed-view chart timescale
The detailed-view chart collapsed every row into a single "today" column
and was additionally capped at 10 points, so the chart never matched the
report's date filters or the table data.
Two causes in get_detailed_view_chart_data:
1. `row.deliver_date` was a typo for `row.delivery_date` (the name used
everywhere else in this report). On a frappe._dict the missing
attribute resolves to None, so `getdate(None)` returned today and the
past-date filter silently compared every row against today instead of
its own delivery date.
2. A hard `if i == 10: break` truncated the chart to 10 date buckets.
Use the correct field name and drop the cap. The null check now runs
before the date comparison, since `getdate(None)` returning today meant
the original ordering could never filter a null delivery_date out.
Fixes #52632
(cherry picked from commit 3c17a604be)
This commit is contained in:
@@ -268,22 +268,17 @@ class MaterialRequirementsPlanningReport:
|
|||||||
|
|
||||||
def get_detailed_view_chart_data(self, data):
|
def get_detailed_view_chart_data(self, data):
|
||||||
chart_data = frappe._dict({})
|
chart_data = frappe._dict({})
|
||||||
i = 0
|
|
||||||
|
|
||||||
sorted_data = sorted(data, key=lambda x: getdate(x.get("delivery_date")))
|
sorted_data = sorted(data, key=lambda x: getdate(x.get("delivery_date")))
|
||||||
for row in sorted_data:
|
for row in sorted_data:
|
||||||
if getdate(row.deliver_date) < getdate(today()):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not row.delivery_date:
|
if not row.delivery_date:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if i == 10:
|
if getdate(row.delivery_date) < getdate(today()):
|
||||||
break
|
continue
|
||||||
|
|
||||||
delivery_date = formatdate(row.delivery_date, "dd MMM")
|
delivery_date = formatdate(row.delivery_date, "dd MMM")
|
||||||
if delivery_date not in chart_data:
|
if delivery_date not in chart_data:
|
||||||
i += 1
|
|
||||||
chart_data[delivery_date] = frappe._dict(
|
chart_data[delivery_date] = frappe._dict(
|
||||||
{
|
{
|
||||||
"demand": 0.0,
|
"demand": 0.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user