From 2c0f6c50df04324425f2d1af6bee7c73c2e6eae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Oberle?= Date: Thu, 28 May 2026 10:52:46 +0200 Subject: [PATCH 1/2] refactor(sales_invoice): replace sql with qb in get_mode_of_payment_info Replace sql with query builder to ensure compatibility with postgres Contribution made on behalf of Orange SA --- .../doctype/sales_invoice/sales_invoice.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 86f84be0973..b9c0dbbfe31 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -3150,15 +3150,23 @@ def get_mode_of_payments_info(mode_of_payments, company): def get_mode_of_payment_info(mode_of_payment, company): - return frappe.db.sql( - """ - select mpa.default_account, mpa.parent, mp.type as type - from `tabMode of Payment Account` mpa,`tabMode of Payment` mp - where mpa.parent = mp.name and mpa.company = %s and mp.enabled = 1 and mp.name = %s""", - (company, mode_of_payment), - as_dict=1, + ModeOfPaymentAccount = frappe.qb.DocType("Mode of Payment Account") + ModeOfPayment = frappe.qb.DocType("Mode of Payment") + + query = ( + frappe.qb.from_(ModeOfPaymentAccount) + .join(ModeOfPayment) + .on(ModeOfPaymentAccount.parent == ModeOfPayment.name) + .select( + ModeOfPaymentAccount.default_account, ModeOfPaymentAccount.parent, ModeOfPayment.type.as_("type") + ) + .where(ModeOfPaymentAccount.company == company) + .where(ModeOfPayment.enabled == 1) + .where(ModeOfPayment.name == mode_of_payment) ) + return query.run(as_dict=1) + @frappe.whitelist() def create_dunning( From 7ee7c4253b58bdd31b03245f7be4dd33566a577d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Oberle?= Date: Tue, 2 Jun 2026 10:42:19 +0200 Subject: [PATCH 2/2] fix(sales_invoice): switch parent and child doctype Switch the parent and child doctype in sales_invoice.py --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b9c0dbbfe31..dc3c87856f9 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -3154,8 +3154,8 @@ def get_mode_of_payment_info(mode_of_payment, company): ModeOfPayment = frappe.qb.DocType("Mode of Payment") query = ( - frappe.qb.from_(ModeOfPaymentAccount) - .join(ModeOfPayment) + frappe.qb.from_(ModeOfPayment) + .join(ModeOfPaymentAccount) .on(ModeOfPaymentAccount.parent == ModeOfPayment.name) .select( ModeOfPaymentAccount.default_account, ModeOfPaymentAccount.parent, ModeOfPayment.type.as_("type")