diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index fa3f80357e2..c1712b09efb 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1258,9 +1258,8 @@ def validate_inter_company_party(doctype, party, company, inter_company_referenc frappe.throw(_("Invalid Company for Inter Company Transaction.")) elif frappe.db.get_value(partytype, {"name": party, internal: 1}, "name") == party: - companies = frappe.db.sql("""select company from `tabAllowed To Transact With` - where parenttype = '{0}' and parent = '{1}'""".format(partytype, party), as_list = 1) - companies = [d[0] for d in companies] + companies = frappe.get_all("Allowed To Transact With", fields=["company"], filters={"parenttype": partytype, "parent": party}) + companies = [d.company for d in companies] if not company in companies: frappe.throw(_("{0} not allowed to transact with {1}. Please change the Company.").format(partytype, company))