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
This commit is contained in:
Loïc Oberle
2026-05-28 10:52:46 +02:00
parent a051049710
commit 2c0f6c50df

View File

@@ -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(