fix(sales-invoice): Use orm instead of frappe.db.sql (#18434)

This commit is contained in:
Aditya Hase 2019-07-22 11:19:07 +05:30 committed by Nabin Hait
parent 195465cdd9
commit dc42cc3998

View File

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