From 59ad76c21e385eab807fae96dd15e748835366de Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 17 Jun 2026 16:08:24 +0530 Subject: [PATCH 1/2] fix(postgres): satisfy strict GROUP BY in asset depreciation query Co-Authored-By: Claude Opus 4.8 (1M context) --- erpnext/assets/doctype/asset/depreciation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index fe0710730d4..762ed796056 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -96,7 +96,9 @@ def get_depreciable_assets_data(date): .where(a.status.isin(["Submitted", "Partially Depreciated"])) .where(ds.journal_entry.isnull()) .where(ds.schedule_date <= date) - .groupby(ads.name) + # a.name/a.creation are constant per ads.name; include them so postgres accepts the + # SELECT and ORDER BY (one row per Asset Depreciation Schedule either way) + .groupby(ads.name, a.name, a.creation) .orderby(a.creation, order=Order.desc) ) From 4ba042c7c776e421033500c5931f965d0161598c Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 17 Jun 2026 16:09:00 +0530 Subject: [PATCH 2/2] fix(postgres): compare Check fields with == 1 in accounts controller CASE/condition disable_rounded_total and is_pos are smallint Check fields; postgres rejects using them as bare boolean conditions in CASE WHEN / bitwise-AND, so compare explicitly against 1. No-op on MariaDB. Co-Authored-By: Claude Opus 4.8 (1M context) --- erpnext/controllers/accounts_controller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ab8fa08902b..45ec35ca592 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1583,13 +1583,13 @@ def update_invoice_status(): total = ( frappe.qb.terms.Case() - .when(invoice.disable_rounded_total, invoice.grand_total) + .when(invoice.disable_rounded_total == 1, invoice.grand_total) .else_(invoice.rounded_total) ) base_total = ( frappe.qb.terms.Case() - .when(invoice.disable_rounded_total, invoice.base_grand_total) + .when(invoice.disable_rounded_total == 1, invoice.base_grand_total) .else_(invoice.base_rounded_total) ) @@ -1602,7 +1602,7 @@ def update_invoice_status(): & (invoice.outstanding_amount > 0) & (invoice.status.like("Unpaid%") | invoice.status.like("Partly Paid%")) & ( - ((invoice.is_pos & invoice.due_date < today) | is_overdue) + (((invoice.is_pos == 1) & (invoice.due_date < today)) | is_overdue) if doctype == "Sales Invoice" else is_overdue )