mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
refactor(sales_invoice): replace sql with qb in validate_proj_cust (#55382)
This commit is contained in:
@@ -1134,12 +1134,20 @@ class SalesInvoice(SellingController):
|
||||
def validate_proj_cust(self):
|
||||
"""check for does customer belong to same project as entered.."""
|
||||
if self.project and self.customer:
|
||||
res = frappe.db.sql(
|
||||
"""select name from `tabProject`
|
||||
where name = %s and (customer = %s or customer is null or customer = '')""",
|
||||
(self.project, self.customer),
|
||||
Project = frappe.qb.DocType("Project")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(Project)
|
||||
.select(Project.name)
|
||||
.where(Project.name == self.project)
|
||||
.where(
|
||||
(Project.customer == self.customer)
|
||||
| (Project.customer.isnull())
|
||||
| (Project.customer == "")
|
||||
)
|
||||
)
|
||||
if not res:
|
||||
|
||||
if not query.run():
|
||||
throw(_("Customer {0} does not belong to project {1}").format(self.customer, self.project))
|
||||
|
||||
def validate_pos(self):
|
||||
|
||||
Reference in New Issue
Block a user