fix: Rewrite patch using query builder

(cherry picked from commit 09a5616e2d)
This commit is contained in:
Deepesh Garg
2021-10-28 19:01:24 +05:30
committed by mergify-bot
parent 1ba0111e16
commit 7a25d5f2de

View File

@@ -2,9 +2,17 @@ import frappe
def execute():
company = frappe.get_all('Company', filters = {'country': 'India'})
if not company:
return
frappe.db.sql("""
UPDATE `tabLower Deduction Certificate` l, `tabSupplier` s
SET l.tax_withholding_category = s.tax_withholding_category
WHERE l.supplier = s.name
""")
ldc = frappe.qb.DocType("Lower Deduction Certificate").as_("ldc")
supplier = frappe.qb.DocType("Supplier")
frappe.qb.update(ldc).inner_join(supplier).on(
ldc.supplier == supplier.name
).set(
ldc.tax_withholding_category, supplier.tax_withholding_category
).where(
ldc.tax_withholding_category.isnull()
).run()