diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py index d3654606613..48ca58cd334 100644 --- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py +++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py @@ -86,12 +86,14 @@ def get_stock_ledger_data(report_filters, filters): "Stock Ledger Entry", filters=filters, fields=[ - "name", + # name is arbitrary per grouped voucher (many SLEs); posting_date/posting_time are constant + # per voucher -> MAX() keeps the GROUP BY valid on postgres with the same values MySQL picked. + {"MAX": "name", "as": "name"}, "voucher_type", "voucher_no", {"SUM": "stock_value_difference", "as": "stock_value"}, - "posting_date", - "posting_time", + {"MAX": "posting_date", "as": "posting_date"}, + {"MAX": "posting_time", "as": "posting_time"}, ], group_by="voucher_type, voucher_no", order_by="posting_date ASC, posting_time ASC", @@ -113,10 +115,12 @@ def get_gl_data(report_filters, filters): "GL Entry", filters=filters, fields=[ - "name", + # name is arbitrary per grouped voucher (many GL entries); posting_date is constant per + # voucher -> MAX() keeps the GROUP BY valid on postgres with the same values MySQL picked. + {"MAX": "name", "as": "name"}, "voucher_type", "voucher_no", - "posting_date", + {"MAX": "posting_date", "as": "posting_date"}, { "SUB": [{"SUM": "debit_in_account_currency"}, {"SUM": "credit_in_account_currency"}], "as": "account_value",