refactor(treewide): formatting and ruff fixes, + manually enabled F401

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang
2024-03-27 11:37:26 +05:30
parent c28d19cf7f
commit 4d34b1ead7
618 changed files with 4188 additions and 6384 deletions

View File

@@ -12,9 +12,7 @@ def execute():
if "barcode" not in frappe.db.get_table_columns("Item"):
return
items_barcode = frappe.db.sql(
"select name, barcode from tabItem where barcode is not null", as_dict=True
)
items_barcode = frappe.db.sql("select name, barcode from tabItem where barcode is not null", as_dict=True)
frappe.reload_doc("stock", "doctype", "item")
for item in items_barcode:

View File

@@ -9,6 +9,4 @@ def execute():
if doc.company:
currency = frappe.get_cached_value("Company", doc.company, "default_currency")
frappe.db.sql(
"""update `tabPricing Rule` set currency = %s where name = %s""", (currency, doc.name)
)
frappe.db.sql("""update `tabPricing Rule` set currency = %s where name = %s""", (currency, doc.name))

View File

@@ -52,7 +52,6 @@ def drop_columns_from_subscription():
"status",
"amended_from",
]:
if field in frappe.db.get_table_columns("Subscription"):
fields_to_drop["Subscription"].append(field)

View File

@@ -53,11 +53,10 @@ def update_records(doctype, comp_dict):
for department in records:
when_then.append(
"""
WHEN company = "%s" and department = "%s"
THEN "%s"
f"""
WHEN company = "{company}" and department = "{department}"
THEN "{records[department]}"
"""
% (company, department, records[department])
)
if not when_then:
@@ -66,11 +65,10 @@ def update_records(doctype, comp_dict):
frappe.db.sql(
"""
update
`tab%s`
`tab{}`
set
department = CASE %s END
"""
% (doctype, " ".join(when_then))
department = CASE {} END
""".format(doctype, " ".join(when_then))
)
@@ -83,11 +81,10 @@ def update_instructors(comp_dict):
for department in records:
when_then.append(
"""
WHEN employee = "%s" and department = "%s"
THEN "%s"
f"""
WHEN employee = "{employee.name}" and department = "{department}"
THEN "{records[department]}"
"""
% (employee.name, department, records[department])
)
if not when_then:

View File

@@ -20,19 +20,17 @@ def execute():
# Set state codes
condition = ""
for state, code in state_codes.items():
condition += " when {0} then {1}".format(frappe.db.escape(state), frappe.db.escape(code))
condition += f" when {frappe.db.escape(state)} then {frappe.db.escape(code)}"
if condition:
condition = "state_code = (case state {0} end),".format(condition)
condition = f"state_code = (case state {condition} end),"
frappe.db.sql(
"""
f"""
UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
from `tabCountry` where name = `tabAddress`.country), ''))
where country_code is null and state_code is null
""".format(
condition=condition
)
"""
)
frappe.db.sql(

View File

@@ -29,9 +29,9 @@ def execute():
rename_field("Linked Location", "land_unit", "location")
if not frappe.db.exists("Location", "All Land Units"):
frappe.get_doc(
{"doctype": "Location", "is_group": True, "location_name": "All Land Units"}
).insert(ignore_permissions=True)
frappe.get_doc({"doctype": "Location", "is_group": True, "location_name": "All Land Units"}).insert(
ignore_permissions=True
)
if frappe.db.table_exists("Land Unit"):
land_units = frappe.get_all("Land Unit", fields=["*"], order_by="lft")

View File

@@ -106,8 +106,6 @@ def execute():
`expense_account`, `income_account`, `buying_cost_center`, `selling_cost_center`
)
VALUES {}
""".format(
", ".join(["%s"] * len(to_insert_data))
),
""".format(", ".join(["%s"] * len(to_insert_data))),
tuple(to_insert_data),
)

View File

@@ -124,9 +124,7 @@ def get_series():
def get_series_to_preserve(doctype):
series_to_preserve = frappe.db.sql_list(
"""select distinct naming_series from `tab{doctype}` where ifnull(naming_series, '') != ''""".format(
doctype=doctype
)
f"""select distinct naming_series from `tab{doctype}` where ifnull(naming_series, '') != ''"""
)
series_to_preserve.sort()
return series_to_preserve

View File

@@ -6,8 +6,6 @@ import frappe
def execute():
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists(
"Asset Value Adjustment"
):
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists("Asset Value Adjustment"):
frappe.rename_doc("DocType", "Asset Adjustment", "Asset Value Adjustment", force=True)
frappe.reload_doc("assets", "doctype", "asset_value_adjustment")

View File

@@ -9,9 +9,7 @@ from frappe.model.utils.rename_field import rename_field
def execute():
# updating column value to handle field change from Data to Currency
changed_field = "base_scrap_material_cost"
frappe.db.sql(
f"update `tabBOM` set {changed_field} = '0' where trim(coalesce({changed_field}, ''))= ''"
)
frappe.db.sql(f"update `tabBOM` set {changed_field} = '0' where trim(coalesce({changed_field}, ''))= ''")
for doctype in ["BOM Explosion Item", "BOM Item", "Work Order Item", "Item"]:
if frappe.db.has_column(doctype, "allow_transfer_for_manufacture"):

View File

@@ -21,14 +21,10 @@ def execute():
rename_field("Timesheet", "production_order", "work_order")
rename_field("Stock Entry", "production_order", "work_order")
frappe.rename_doc(
"Report", "Production Orders in Progress", "Work Orders in Progress", force=True
)
frappe.rename_doc("Report", "Production Orders in Progress", "Work Orders in Progress", force=True)
frappe.rename_doc("Report", "Completed Production Orders", "Completed Work Orders", force=True)
frappe.rename_doc("Report", "Open Production Orders", "Open Work Orders", force=True)
frappe.rename_doc(
"Report", "Issued Items Against Production Order", "Issued Items Against Work Order", force=True
)
frappe.rename_doc(
"Report", "Production Order Stock Report", "Work Order Stock Report", force=True
)
frappe.rename_doc("Report", "Production Order Stock Report", "Work Order Stock Report", force=True)

View File

@@ -25,10 +25,8 @@ def execute():
def build_tree():
frappe.db.sql(
"""update `tabSupplier Group` set parent_supplier_group = '{0}'
where is_group = 0""".format(
_("All Supplier Groups")
)
"""update `tabSupplier Group` set parent_supplier_group = '{}'
where is_group = 0""".format(_("All Supplier Groups"))
)
if not frappe.db.exists("Supplier Group", _("All Supplier Groups")):

View File

@@ -4,7 +4,6 @@ import frappe
def execute():
doctypes_to_update = {
"projects": ["Activity Cost", "Timesheet"],
"setup": ["Sales Person"],

View File

@@ -4,7 +4,6 @@ from frappe.model.workflow import get_workflow_name
def execute():
for doctype in ["Expense Claim", "Leave Application"]:
active_workflow = get_workflow_name(doctype)
if not active_workflow:
continue

View File

@@ -16,12 +16,10 @@ def execute():
frappe.reload_doc("manufacturing", "doctype", frappe.scrub(doctype))
frappe.db.sql(
""" update `tab{0}` child, tabItem item
f""" update `tab{doctype}` child, tabItem item
set
child.include_item_in_manufacturing = 1
where
child.item_code = item.name and ifnull(item.is_stock_item, 0) = 1
""".format(
doctype
)
"""
)

View File

@@ -7,9 +7,7 @@ import frappe
def execute():
frappe.reload_doc("buying", "doctype", "buying_settings")
frappe.db.set_value(
"Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM"
)
frappe.db.set_value("Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM")
frappe.reload_doc("stock", "doctype", "stock_entry_detail")
frappe.db.sql(

View File

@@ -12,10 +12,8 @@ def execute():
).insert(ignore_permissions=True, ignore_mandatory=True)
frappe.db.sql(
"""update `tabDepartment` set parent_department = '{0}'
where is_group = 0""".format(
_("All Departments")
)
"""update `tabDepartment` set parent_department = '{}'
where is_group = 0""".format(_("All Departments"))
)
rebuild_tree("Department", "parent_department")

View File

@@ -16,7 +16,7 @@ def execute():
# get partner type in existing forms (customized)
# and create a document if not created
for d in ["Sales Partner"]:
partner_type = frappe.db.sql_list("select distinct partner_type from `tab{0}`".format(d))
partner_type = frappe.db.sql_list(f"select distinct partner_type from `tab{d}`")
for s in partner_type:
if s and s not in default_sales_partner_type:
insert_sales_partner_type(s)

View File

@@ -24,16 +24,14 @@ def execute():
for doctype in doctypes:
total_qty = frappe.db.sql(
"""
f"""
SELECT
parent, SUM(qty) as qty
FROM
`tab{0} Item`
where parenttype = '{0}'
`tab{doctype} Item`
where parenttype = '{doctype}'
GROUP BY parent
""".format(
doctype
),
""",
as_dict=True,
)
@@ -53,13 +51,11 @@ def execute():
# This is probably never used anywhere else as of now, but should be
values = []
for d in batch_transactions:
values.append("({0}, {1})".format(frappe.db.escape(d.parent), d.qty))
values.append(f"({frappe.db.escape(d.parent)}, {d.qty})")
conditions = ",".join(values)
frappe.db.sql(
"""
INSERT INTO `tab{}` (name, total_qty) VALUES {}
f"""
INSERT INTO `tab{doctype}` (name, total_qty) VALUES {conditions}
ON DUPLICATE KEY UPDATE name = VALUES(name), total_qty = VALUES(total_qty)
""".format(
doctype, conditions
)
"""
)

View File

@@ -8,9 +8,7 @@ import frappe
def execute():
frappe.reload_doc("manufacturing", "doctype", "job_card_time_log")
if frappe.db.table_exists("Job Card") and frappe.get_meta("Job Card").has_field(
"actual_start_date"
):
if frappe.db.table_exists("Job Card") and frappe.get_meta("Job Card").has_field("actual_start_date"):
time_logs = []
for d in frappe.get_all(
"Job Card",
@@ -37,9 +35,7 @@ def execute():
`tabJob Card Time Log`
(from_time, to_time, time_in_mins, completed_qty, parent, parenttype, parentfield, name)
values {values}
""".format(
values=",".join(["%s"] * len(time_logs))
),
""".format(values=",".join(["%s"] * len(time_logs))),
tuple(time_logs),
)

View File

@@ -8,14 +8,10 @@ import frappe
def execute():
frappe.reload_doctype("Quotation")
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = lead WHERE quotation_to = 'Lead' """)
frappe.db.sql(
""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """
)
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """)
frappe.reload_doctype("Opportunity")
frappe.db.sql(
""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """
)
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """)
frappe.db.sql(
""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """
)

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
frappe.reload_doctype("Opportunity")
if frappe.db.has_column("Opportunity", "enquiry_from"):
frappe.db.sql(
@@ -10,9 +9,7 @@ def execute():
where ifnull(opportunity_from, '') = '' and ifnull(enquiry_from, '') != ''"""
)
if frappe.db.has_column("Opportunity", "lead") and frappe.db.has_column(
"Opportunity", "enquiry_from"
):
if frappe.db.has_column("Opportunity", "lead") and frappe.db.has_column("Opportunity", "enquiry_from"):
frappe.db.sql(
""" UPDATE `tabOpportunity` set party_name = lead
where enquiry_from = 'Lead' and ifnull(party_name, '') = '' and ifnull(lead, '') != ''"""

View File

@@ -11,9 +11,7 @@ def execute():
if frappe.db.has_column("Company", "default_terms"):
rename_field("Company", "default_terms", "default_selling_terms")
for company in frappe.get_all(
"Company", ["name", "default_selling_terms", "default_buying_terms"]
):
for company in frappe.get_all("Company", ["name", "default_selling_terms", "default_buying_terms"]):
if company.default_selling_terms and not company.default_buying_terms:
frappe.db.set_value(
"Company", company.name, "default_buying_terms", company.default_selling_terms

View File

@@ -3,7 +3,6 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field
def execute():
frappe.reload_doc("accounts", "doctype", "accounting_dimension")
accounting_dimensions = frappe.db.sql(
@@ -17,7 +16,6 @@ def execute():
count = 1
for d in accounting_dimensions:
if count % 2 == 0:
insert_after_field = "dimension_col_break"
else:
@@ -31,7 +29,6 @@ def execute():
"Expense Claim Detail",
"Expense Taxes and Charges",
]:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
if field:

View File

@@ -4,7 +4,6 @@ from erpnext.regional.united_states.setup import make_custom_fields
def execute():
frappe.reload_doc("accounts", "doctype", "allowed_to_transact_with", force=True)
frappe.reload_doc("accounts", "doctype", "pricing_rule_detail", force=True)
frappe.reload_doc("crm", "doctype", "lost_reason_detail", force=True)

View File

@@ -16,9 +16,7 @@ def execute():
and qo.valid_till < so.transaction_date""" # check if SO was created after quotation expired
frappe.db.sql(
"""UPDATE `tabQuotation` qo SET qo.status = 'Expired' WHERE {cond} and exists({invalid_so_against_quo})""".format(
cond=cond, invalid_so_against_quo=invalid_so_against_quo
)
f"""UPDATE `tabQuotation` qo SET qo.status = 'Expired' WHERE {cond} and exists({invalid_so_against_quo})"""
)
valid_so_against_quo = """
@@ -31,7 +29,5 @@ def execute():
and qo.valid_till >= so.transaction_date""" # check if SO was created before quotation expired
frappe.db.sql(
"""UPDATE `tabQuotation` qo SET qo.status = 'Closed' WHERE {cond} and exists({valid_so_against_quo})""".format(
cond=cond, valid_so_against_quo=valid_so_against_quo
)
f"""UPDATE `tabQuotation` qo SET qo.status = 'Closed' WHERE {cond} and exists({valid_so_against_quo})"""
)

View File

@@ -30,8 +30,6 @@ def execute():
"""
INSERT INTO `tabItem Manufacturer`
(`name`, `item_code`, `manufacturer`, `manufacturer_part_no`, `creation`, `owner`)
VALUES {}""".format(
", ".join(["%s"] * len(item_manufacturer))
),
VALUES {}""".format(", ".join(["%s"] * len(item_manufacturer))),
tuple(item_manufacturer),
)

View File

@@ -16,7 +16,7 @@ def execute():
SET b.swift_number = ba.swift_number WHERE b.name = ba.bank
"""
)
except Exception as e:
except Exception:
frappe.log_error("Bank to Bank Account patch migration failed")
frappe.reload_doc("accounts", "doctype", "bank_account")

View File

@@ -29,12 +29,10 @@ def move_credit_limit_to_child_table():
fields = ", bypass_credit_limit_check_at_sales_order"
credit_limit_records = frappe.db.sql(
"""
SELECT name, credit_limit {0}
FROM `tab{1}` where credit_limit > 0
""".format(
fields, doctype
),
f"""
SELECT name, credit_limit {fields}
FROM `tab{doctype}` where credit_limit > 0
""",
as_dict=1,
) # nosec

View File

@@ -80,11 +80,9 @@ def execute():
for dt in doctypes:
for d in frappe.db.sql(
"""select name, parenttype, parent, item_code, item_tax_rate from `tab{0} Item`
f"""select name, parenttype, parent, item_code, item_tax_rate from `tab{dt} Item`
where ifnull(item_tax_rate, '') not in ('', '{{}}')
and item_tax_template is NULL""".format(
dt
),
and item_tax_template is NULL""",
as_dict=1,
):
item_tax_map = json.loads(d.item_tax_rate)
@@ -145,13 +143,23 @@ def get_item_tax_template(
if not parent_account:
parent_account = frappe.db.get_value(
"Account",
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company},
filters={
"account_type": "Tax",
"root_type": "Liability",
"is_group": 0,
"company": company,
},
fieldname="parent_account",
)
if not parent_account:
parent_account = frappe.db.get_value(
"Account",
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 1, "company": company},
filters={
"account_type": "Tax",
"root_type": "Liability",
"is_group": 1,
"company": company,
},
)
filters = {
"account_name": account_name,

View File

@@ -18,9 +18,7 @@ def execute():
WHERE
`tab{child_doc}`.parent = `tab{parent_doc}`.name
and `tab{parent_doc}`.distribution_id is not null and `tab{parent_doc}`.distribution_id != ''
""".format(
parent_doc=d, child_doc="Target Detail"
)
""".format(parent_doc=d, child_doc="Target Detail")
)
frappe.delete_doc("Report", "Sales Partner-wise Transaction Summary")

View File

@@ -17,16 +17,14 @@ def execute():
if not affected_purchase_receipts:
return
logger.info(
"purchase_receipt_status: begin patch, PR count: {}".format(len(affected_purchase_receipts))
)
logger.info(f"purchase_receipt_status: begin patch, PR count: {len(affected_purchase_receipts)}")
frappe.reload_doc("stock", "doctype", "Purchase Receipt")
frappe.reload_doc("stock", "doctype", "Purchase Receipt Item")
for pr in affected_purchase_receipts:
pr_name = pr[0]
logger.info("purchase_receipt_status: patching PR - {}".format(pr_name))
logger.info(f"purchase_receipt_status: patching PR - {pr_name}")
pr_doc = frappe.get_doc("Purchase Receipt", pr_name)

View File

@@ -6,12 +6,8 @@ import frappe
def _rename_single_field(**kwargs):
count = frappe.db.sql(
"SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(
**kwargs
)
)[0][
0
] # nosec
"SELECT COUNT(*) FROM tabSingles WHERE doctype='{doctype}' AND field='{new_name}';".format(**kwargs)
)[0][0] # nosec
if count == 0:
frappe.db.sql(
"UPDATE tabSingles SET field='{new_name}' WHERE doctype='{doctype}' AND field='{old_name}';".format(
@@ -22,7 +18,5 @@ def _rename_single_field(**kwargs):
def execute():
_rename_single_field(doctype="Bank Clearance", old_name="bank_account", new_name="account")
_rename_single_field(
doctype="Bank Clearance", old_name="bank_account_no", new_name="bank_account"
)
_rename_single_field(doctype="Bank Clearance", old_name="bank_account_no", new_name="bank_account")
frappe.reload_doc("Accounts", "doctype", "Bank Clearance")

View File

@@ -41,35 +41,29 @@ def execute():
cond = " AND parent_doc.update_stock = 1"
data = frappe.db.sql(
""" SELECT parent_doc.name as name, child_doc.name as child_name
f""" SELECT parent_doc.name as name, child_doc.name as child_name
FROM
`tab{doctype}` parent_doc, `tab{doctype} Item` child_doc
WHERE
parent_doc.name = child_doc.parent AND parent_doc.docstatus < 2
AND child_doc.target_warehouse is not null AND child_doc.target_warehouse != ''
AND child_doc.creation > '2020-04-16' {cond}
""".format(
doctype=doctype, cond=cond
),
""",
as_dict=1,
)
if data:
names = [d.child_name for d in data]
frappe.db.sql(
""" UPDATE `tab{0} Item` set target_warehouse = null
WHERE name in ({1}) """.format(
doctype, ",".join(["%s"] * len(names))
),
""" UPDATE `tab{} Item` set target_warehouse = null
WHERE name in ({}) """.format(doctype, ",".join(["%s"] * len(names))),
tuple(names),
)
frappe.db.sql(
""" UPDATE `tabPacked Item` set target_warehouse = null
WHERE parenttype = '{0}' and parent_detail_docname in ({1})
""".format(
doctype, ",".join(["%s"] * len(names))
),
WHERE parenttype = '{}' and parent_detail_docname in ({})
""".format(doctype, ",".join(["%s"] * len(names))),
tuple(names),
)

View File

@@ -2,17 +2,14 @@ import frappe
def execute():
frappe.reload_doc("selling", "doctype", "sales_order_item", force=True)
frappe.reload_doc("buying", "doctype", "purchase_order_item", force=True)
for doctype in ("Sales Order Item", "Purchase Order Item"):
frappe.db.sql(
"""
UPDATE `tab{0}`
f"""
UPDATE `tab{doctype}`
SET against_blanket_order = 1
WHERE ifnull(blanket_order, '') != ''
""".format(
doctype
)
"""
)

View File

@@ -4,6 +4,4 @@ import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "accounts_settings")
frappe.db.set_value(
"Accounts Settings", None, "automatically_process_deferred_accounting_entry", 1
)
frappe.db.set_value("Accounts Settings", None, "automatically_process_deferred_accounting_entry", 1)

View File

@@ -12,6 +12,5 @@ def execute():
fields=["sales_order", "sales_order_item"],
filters={"sales_order": ("!=", ""), "sales_order_item": ("!=", "")},
):
# update produced qty in sales order
update_produced_qty_in_so_item(d.sales_order, d.sales_order_item)

View File

@@ -4,7 +4,6 @@ import frappe
def execute():
frappe.reload_doc("stock", "doctype", "delivery_note_item", force=True)
frappe.reload_doc("stock", "doctype", "purchase_receipt_item", force=True)
@@ -50,14 +49,12 @@ def execute():
Format => { 'document' : ['return_document_1','return_document_2'] }"""
return_against_documents = frappe.db.sql(
"""
f"""
SELECT
return_against as document, name as return_document
FROM `tab{doctype}`
WHERE
is_return = 1 and docstatus = 1""".format(
doctype=doctype
),
is_return = 1 and docstatus = 1""",
as_dict=1,
) # nosec
@@ -72,7 +69,7 @@ def execute():
return_document_map = defaultdict(list)
detail_field = "purchase_receipt_item" if doctype == "Purchase Receipt" else "dn_detail"
child_doc = frappe.scrub("{0} Item".format(doctype))
child_doc = frappe.scrub(f"{doctype} Item")
frappe.reload_doc("stock", "doctype", child_doc)
return_document_map = make_return_document_map(doctype, return_document_map)
@@ -89,7 +86,8 @@ def execute():
for return_item in return_doc_items:
for doc_item in doc_items:
if (
row_is_mappable(doc_item, return_item, detail_field) and doc_item.get("name") not in mapped
row_is_mappable(doc_item, return_item, detail_field)
and doc_item.get("name") not in mapped
):
map_rows(doc_item, return_item, detail_field, doctype)
mapped.append(doc_item.get("name"))

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
frappe.db.sql(
""" UPDATE `tabQuotation` set status = 'Open'
where docstatus = 1 and status = 'Submitted' """

View File

@@ -10,7 +10,7 @@ def execute():
)
if property_setter_name:
property_setter = frappe.get_doc("Property Setter", property_setter_name)
if not "Completed" in property_setter.value:
if "Completed" not in property_setter.value:
property_setter.value = property_setter.value + "\nCompleted"
property_setter.save()

View File

@@ -28,7 +28,6 @@ def create_stock_entry_types():
"Repack",
"Send to Subcontractor",
]:
ste_type = frappe.get_doc({"doctype": "Stock Entry Type", "name": purpose, "purpose": purpose})
try:

View File

@@ -11,14 +11,12 @@ def execute():
condition = " and doc.per_ordered < 100 and doc.material_request_type = 'Manufacture'"
frappe.db.sql(
""" UPDATE `tab{doc}` as doc, `tab{doc} Item` as child_doc, tabItem as item
f""" UPDATE `tab{doctype}` as doc, `tab{doctype} Item` as child_doc, tabItem as item
SET
child_doc.bom_no = item.default_bom
WHERE
child_doc.item_code = item.name and child_doc.docstatus < 2
and child_doc.parent = doc.name
and item.default_bom is not null and item.default_bom != '' {cond}
""".format(
doc=doctype, cond=condition
)
and item.default_bom is not null and item.default_bom != '' {condition}
"""
)

View File

@@ -17,20 +17,16 @@ def execute():
continue
frappe.db.sql(
"""
f"""
UPDATE `tab{doctype}`
SET is_cancelled = 0
where is_cancelled in ('', 'No') or is_cancelled is NULL""".format(
doctype=doctype
)
where is_cancelled in ('', 'No') or is_cancelled is NULL"""
)
frappe.db.sql(
"""
f"""
UPDATE `tab{doctype}`
SET is_cancelled = 1
where is_cancelled = 'Yes'""".format(
doctype=doctype
)
where is_cancelled = 'Yes'"""
)
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))

View File

@@ -19,8 +19,7 @@ def execute():
"""
UPDATE `tabCustom Field`
SET owner = 'Administrator'
WHERE fieldname = %s
AND dt IN (%s)"""
% ("%s", ", ".join(["%s"] * len(doclist))), # nosec
tuple([dimension.fieldname] + doclist),
WHERE fieldname = {}
AND dt IN ({})""".format("%s", ", ".join(["%s"] * len(doclist))), # nosec
tuple([dimension.fieldname, *doclist]),
)

View File

@@ -8,7 +8,6 @@ parentfield = {"item_code": "items", "item_group": "item_groups", "brand": "bran
def execute():
if not frappe.get_all("Pricing Rule", limit=1):
return
@@ -33,20 +32,16 @@ def execute():
child_doctype = doctype + " Item"
frappe.db.sql(
""" UPDATE `tab{child_doctype}` SET pricing_rules = pricing_rule
f""" UPDATE `tab{child_doctype}` SET pricing_rules = pricing_rule
WHERE docstatus < 2 and pricing_rule is not null and pricing_rule != ''
""".format(
child_doctype=child_doctype
)
"""
)
data = frappe.db.sql(
""" SELECT pricing_rule, name, parent,
f""" SELECT pricing_rule, name, parent,
parenttype, creation, modified, docstatus, modified_by, owner, name
FROM `tab{child_doc}` where docstatus < 2 and pricing_rule is not null
and pricing_rule != ''""".format(
child_doc=child_doctype
),
FROM `tab{child_doctype}` where docstatus < 2 and pricing_rule is not null
and pricing_rule != ''""",
as_dict=1,
)
@@ -73,9 +68,7 @@ def execute():
""" INSERT INTO
`tabPricing Rule Detail` (`pricing_rule`, `child_docname`, `parent`, `parentfield`, `parenttype`,
`creation`, `modified`, `docstatus`, `modified_by`, `owner`, `name`)
VALUES {values} """.format(
values=", ".join(["%s"] * len(values))
),
VALUES {values} """.format(values=", ".join(["%s"] * len(values))),
tuple(values),
)
@@ -116,8 +109,6 @@ def execute():
""" INSERT INTO
`tab{doctype}` ({field}, parent, parentfield, parenttype, creation, modified,
owner, modified_by, name)
VALUES {values} """.format(
doctype=doctype, field=field, values=", ".join(["%s"] * len(values))
),
VALUES {values} """.format(doctype=doctype, field=field, values=", ".join(["%s"] * len(values))),
tuple(values),
)

View File

@@ -21,7 +21,6 @@ def delete_broken_bins():
def delete_and_patch_duplicate_bins():
duplicate_bins = frappe.db.sql(
"""
SELECT

View File

@@ -7,6 +7,4 @@ def execute():
for company in frappe.get_all("Company", pluck="name"):
default_cost_center = frappe.db.get_value("Company", company, "cost_center")
frappe.qb.update(loan).set(loan.cost_center, default_cost_center).where(
loan.company == company
).run()
frappe.qb.update(loan).set(loan.cost_center, default_cost_center).where(loan.company == company).run()

View File

@@ -13,9 +13,7 @@ def execute():
return
frappe.reload_doc("manufacturing", "doctype", "manufacturing_settings")
if cint(
frappe.db.get_single_value("Manufacturing Settings", "make_serial_no_batch_from_work_order")
):
if cint(frappe.db.get_single_value("Manufacturing Settings", "make_serial_no_batch_from_work_order")):
return
frappe.reload_doc("manufacturing", "doctype", "work_order")
@@ -76,9 +74,7 @@ def execute():
def set_expense_account(doc):
for row in doc.items:
if row.is_finished_item and not row.expense_account:
row.expense_account = frappe.get_cached_value(
"Company", doc.company, "stock_adjustment_account"
)
row.expense_account = frappe.get_cached_value("Company", doc.company, "stock_adjustment_account")
def repost_stock_entry(doc):

View File

@@ -4,9 +4,7 @@ import frappe
def execute():
global_search_settings = frappe.get_single("Global Search Settings")
if "Purchase Order" in (
dt.document_type for dt in global_search_settings.allowed_in_global_search
):
if "Purchase Order" in (dt.document_type for dt in global_search_settings.allowed_in_global_search):
return
global_search_settings.append("allowed_in_global_search", {"document_type": "Purchase Order"})

View File

@@ -2,7 +2,6 @@ import click
def execute():
click.secho(
"Agriculture Domain is moved to a separate app and will be removed from ERPNext in version-14.\n"
"Please install the app to continue using the Agriculture domain: https://github.com/frappe/agriculture",

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
# Erase all default item manufacturers that dont exist.
item = frappe.qb.DocType("Item")
manufacturer = frappe.qb.DocType("Manufacturer")

View File

@@ -6,9 +6,7 @@ def execute():
params = set()
# get all parameters from QI readings table
for (p,) in frappe.db.get_all(
"Quality Inspection Reading", fields=["specification"], as_list=True
):
for (p,) in frappe.db.get_all("Quality Inspection Reading", fields=["specification"], as_list=True):
params.add(p.strip())
# get all parameters from QI Template as some may be unused in QI

View File

@@ -1,5 +1,4 @@
import json
from typing import List, Union
import frappe
@@ -42,7 +41,7 @@ def execute():
)
def generate_fields_to_edit() -> List:
def generate_fields_to_edit() -> list:
fields = []
for i in range(1, 13):
fields.append(f"card_{i}_item") # fields like 'card_1_item', etc.
@@ -50,7 +49,7 @@ def generate_fields_to_edit() -> List:
return fields
def make_new_website_item(item: str) -> Union[str, None]:
def make_new_website_item(item: str) -> str | None:
try:
doc = frappe.get_doc("Item", item)
web_item = make_website_item(doc) # returns [website_item.name, item_name]

View File

@@ -84,11 +84,9 @@ def execute():
move_table_multiselect_data(df)
else:
frappe.db.sql( # nosemgrep
"""
f"""
UPDATE `tabWebsite Item` wi, `tabItem` i
SET wi.{0} = i.{0}
SET wi.{row.fieldname} = i.{row.fieldname}
WHERE wi.item_code = i.item_code
""".format(
row.fieldname
)
"""
)

View File

@@ -12,14 +12,12 @@ def execute():
count = 1
for d in accounting_dimensions:
if count % 2 == 0:
insert_after_field = "dimension_col_break"
else:
insert_after_field = "accounting_dimensions_section"
for doctype in ["Purchase Order", "Purchase Receipt", "Sales Order"]:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
if field:
@@ -36,7 +34,7 @@ def execute():
try:
create_custom_field(doctype, df, ignore_validate=True)
frappe.clear_cache(doctype=doctype)
except Exception as e:
except Exception:
pass
count += 1

View File

@@ -15,14 +15,12 @@ def execute():
count = 1
for d in accounting_dimensions:
if count % 2 == 0:
insert_after_field = "dimension_col_break"
else:
insert_after_field = "accounting_dimensions_section"
for doctype in ["POS Invoice", "POS Invoice Item"]:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
if field:

View File

@@ -8,9 +8,7 @@ from erpnext.regional.united_arab_emirates.setup import make_custom_fields
def execute():
company = frappe.get_all(
"Company", filters={"country": ["in", ["Saudi Arabia", "United Arab Emirates"]]}
)
company = frappe.get_all("Company", filters={"country": ["in", ["Saudi Arabia", "United Arab Emirates"]]})
if not company:
return

View File

@@ -9,9 +9,7 @@ def execute():
if not company:
return
TAXJAR_CREATE_TRANSACTIONS = frappe.db.get_single_value(
"TaxJar Settings", "taxjar_create_transactions"
)
TAXJAR_CREATE_TRANSACTIONS = frappe.db.get_single_value("TaxJar Settings", "taxjar_create_transactions")
TAXJAR_CALCULATE_TAX = frappe.db.get_single_value("TaxJar Settings", "taxjar_calculate_tax")
TAXJAR_SANDBOX_MODE = frappe.db.get_single_value("TaxJar Settings", "is_sandbox")

View File

@@ -6,9 +6,7 @@ import frappe
def execute():
if frappe.db.exists("DocType", "Bank Reconciliation Detail") and frappe.db.exists(
"DocType", "Bank Clearance Detail"
):
frappe.delete_doc("DocType", "Bank Reconciliation Detail", force=1)

View File

@@ -11,6 +11,4 @@ def execute():
company.enable_perpetual_inventory_for_non_stock_items,
).set(company.default_provisional_account, company.service_received_but_not_billed).where(
company.enable_perpetual_inventory_for_non_stock_items == 1
).where(
company.service_received_but_not_billed.isnotnull()
).run()
).where(company.service_received_but_not_billed.isnotnull()).run()

View File

@@ -1,4 +1,4 @@
from typing import List, NewType
from typing import NewType
import frappe
@@ -13,7 +13,7 @@ def execute():
create_repost_item_valuation(patched_stock_entry)
def find_broken_stock_entries() -> List[StockEntryCode]:
def find_broken_stock_entries() -> list[StockEntryCode]:
period_closing_date = frappe.db.get_value(
"Period Closing Voucher", {"docstatus": 1}, "posting_date", order_by="posting_date desc"
)

View File

@@ -41,7 +41,7 @@ def execute():
("Overdue", "Overdue and Discounted", "Partly Paid", "Partly Paid and Discounted"),
),
"outstanding_amount": (">", 0),
"modified": (">", "2021-01-01")
"modified": (">", "2021-01-01"),
# an assumption is being made that only invoices modified
# after 2021 got affected as incorrectly overdue.
# required for performance reasons.

View File

@@ -2,7 +2,6 @@ import click
def execute():
click.secho(
"Healthcare Module is moved to a separate app and will be removed from ERPNext in version-14.\n"
"Please install the app to continue using the module: https://github.com/frappe/healthcare",

View File

@@ -2,7 +2,6 @@ import click
def execute():
click.secho(
"Hospitality domain is moved to a separate app and will be removed from ERPNext in version-14.\n"
"When upgrading to ERPNext version-14, please install the app to continue using the Hospitality domain: https://github.com/frappe/hospitality",

View File

@@ -4,7 +4,6 @@ from erpnext.utilities.naming import set_by_naming_series
def execute():
stock_settings = frappe.get_doc("Stock Settings")
set_by_naming_series(

View File

@@ -6,13 +6,10 @@ import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "bank_account")
frappe.reload_doc("accounts", "doctype", "bank")
if frappe.db.has_column("Bank", "branch_code") and frappe.db.has_column(
"Bank Account", "branch_code"
):
if frappe.db.has_column("Bank", "branch_code") and frappe.db.has_column("Bank Account", "branch_code"):
frappe.db.sql(
"""UPDATE `tabBank` b, `tabBank Account` ba
SET ba.branch_code = b.branch_code

View File

@@ -2,7 +2,6 @@ import click
def execute():
click.secho(
"Non Profit Domain is moved to a separate app and will be removed from ERPNext in version-14.\n"
"When upgrading to ERPNext version-14, please install the app to continue using the Non Profit domain: https://github.com/frappe/non_profit",

View File

@@ -57,7 +57,11 @@ def execute():
for entry in opportunities:
mins_to_first_response = convert_to_seconds(entry.mins_to_first_response, "Minutes")
frappe.db.set_value(
"Opportunity", entry.name, "first_response_time", mins_to_first_response, update_modified=False
"Opportunity",
entry.name,
"first_response_time",
mins_to_first_response,
update_modified=False,
)
# commit after every 100 updates
count += 1

View File

@@ -3,7 +3,6 @@ from frappe.utils import cstr
def execute():
reposts = frappe.get_all(
"Repost Item Valuation",
{"status": "Failed", "modified": [">", "2021-10-05"]},

View File

@@ -20,9 +20,9 @@ def execute():
.run(as_dict=True)
)
frappe.qb.update(dn_item).inner_join(dn).on(dn.name == dn_item.parent).set(
dn_item.returned_qty, 0
).where(dn.is_return == 1).where(dn_item.returned_qty > 0).run()
frappe.qb.update(dn_item).inner_join(dn).on(dn.name == dn_item.parent).set(dn_item.returned_qty, 0).where(
dn.is_return == 1
).where(dn_item.returned_qty > 0).run()
for d in dn_list:
dn_doc = frappe.get_doc("Delivery Note", d.get("name"))

View File

@@ -28,9 +28,7 @@ def execute():
results = query.run(as_dict=True)
for row in results:
so_item = frappe.get_value(
"Material Request Item", row.material_request_item, "sales_order_item"
)
so_item = frappe.get_value("Material Request Item", row.material_request_item, "sales_order_item")
frappe.db.set_value("Work Order", row.name, "sales_order_item", so_item)
if so_item:

View File

@@ -2,7 +2,6 @@ import click
def execute():
click.secho(
"Shopify Integration is moved to a separate app and will be removed from ERPNext in version-14.\n"
"Please install the app to continue using the integration: https://github.com/frappe/ecommerce_integrations",

View File

@@ -3,7 +3,6 @@ import frappe
def execute():
frappe.delete_doc("DocType", "Shopping Cart Settings", ignore_missing=True)
frappe.delete_doc("DocType", "Products Settings", ignore_missing=True)
frappe.delete_doc("DocType", "Supplier Item Group", ignore_missing=True)
@@ -13,7 +12,6 @@ def execute():
def notify_users():
click.secho(
"Shopping cart and Product settings are merged into E-commerce settings.\n"
"Checkout the documentation to learn more:"

View File

@@ -38,9 +38,7 @@ def execute():
if correct_sr_no == sle.serial_no:
continue
frappe.db.set_value(
"Stock Ledger Entry", sle.name, "serial_no", correct_sr_no, update_modified=False
)
frappe.db.set_value("Stock Ledger Entry", sle.name, "serial_no", correct_sr_no, update_modified=False)
broken_serial_nos.update(serial_no_list)
if not broken_serial_nos:

View File

@@ -14,6 +14,4 @@ def execute():
lr.payment_account, loan.payment_account
).set(lr.loan_account, loan.loan_account).set(
lr.penalty_income_account, loan.penalty_income_account
).where(
lr.docstatus < 2
).run()
).where(lr.docstatus < 2).run()

View File

@@ -29,7 +29,7 @@ def execute():
)
if not doc.planned_end_date:
planned_end_date = add_to_date(doc.planned_start_date, minutes=doc.lead_time)
add_to_date(doc.planned_start_date, minutes=doc.lead_time)
doc.db_set("planned_end_date", doc.actual_start_date, update_modified=False)
frappe.db.sql(

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
frappe.reload_doc("loan_management", "doctype", "loan_type")
frappe.reload_doc("loan_management", "doctype", "loan")

View File

@@ -5,7 +5,6 @@ import frappe
def execute():
job_card = frappe.qb.DocType("Job Card")
(
frappe.qb.update(job_card)

View File

@@ -13,8 +13,6 @@ def execute():
frappe.qb.update(mv).join(mvp).on(mvp.parent == mv.name).set(
mv.maintenance_schedule, Coalesce(mvp.prevdoc_docname, "")
).where(
(mv.maintenance_type == "Scheduled") & (mvp.prevdoc_docname.notnull()) & (mv.docstatus < 2)
).run(
).where((mv.maintenance_type == "Scheduled") & (mvp.prevdoc_docname.notnull()) & (mv.docstatus < 2)).run(
as_dict=1
)

View File

@@ -13,7 +13,6 @@ from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_
def execute():
# Create a penalty account for loan types
frappe.reload_doc("loan_management", "doctype", "loan_type")
@@ -111,9 +110,7 @@ def execute():
loan_type_name = create_loan_type(loan, loan_type_name, penalty_account)
# update loan type in loan
frappe.db.sql(
"UPDATE `tabLoan` set loan_type = %s where name = %s", (loan_type_name, loan.name)
)
frappe.db.sql("UPDATE `tabLoan` set loan_type = %s where name = %s", (loan_type_name, loan.name))
loan_type = loan_type_name
if loan_type_name not in updated_loan_types:

View File

@@ -4,7 +4,6 @@ from erpnext.stock.utils import get_bin
def execute():
wo = frappe.qb.DocType("Work Order")
wo_item = frappe.qb.DocType("Work Order Item")

View File

@@ -5,7 +5,5 @@ def execute():
bom = frappe.qb.DocType("BOM")
(
frappe.qb.update(bom)
.set(bom.transfer_material_against, "Work Order")
.where(bom.with_operations == 0)
frappe.qb.update(bom).set(bom.transfer_material_against, "Work Order").where(bom.with_operations == 0)
).run()

View File

@@ -9,6 +9,6 @@ def execute():
loan_type.repayment_schedule_type, "Monthly as per repayment start date"
).where(loan_type.is_term_loan == 1).run()
frappe.qb.update(loan).set(
loan.repayment_schedule_type, "Monthly as per repayment start date"
).where(loan.is_term_loan == 1).run()
frappe.qb.update(loan).set(loan.repayment_schedule_type, "Monthly as per repayment start date").where(
loan.is_term_loan == 1
).run()

View File

@@ -39,14 +39,16 @@ def execute():
for priority in priorities:
if priority.parenttype == "Service Level Agreement":
response_time = convert_to_seconds(priority.response_time, priority.response_time_period)
resolution_time = convert_to_seconds(priority.resolution_time, priority.resolution_time_period)
resolution_time = convert_to_seconds(
priority.resolution_time, priority.resolution_time_period
)
frappe.db.set_value(
"Service Level Priority",
priority.name,
{"response_time": response_time, "resolution_time": resolution_time},
)
if priority.parenttype == "Service Level":
if not priority.parent in priority_dict:
if priority.parent not in priority_dict:
priority_dict[priority.parent] = []
priority_dict[priority.parent].append(priority)
@@ -86,7 +88,9 @@ def execute():
{
"priority": priority.priority,
"default_priority": priority.default_priority,
"response_time": convert_to_seconds(priority.response_time, priority.response_time_period),
"response_time": convert_to_seconds(
priority.response_time, priority.response_time_period
),
"resolution_time": convert_to_seconds(
priority.resolution_time, priority.resolution_time_period
),

View File

@@ -6,7 +6,6 @@ import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "subscription")
frappe.reload_doc("accounts", "doctype", "subscription_invoice")
frappe.reload_doc("accounts", "doctype", "subscription_plan")

View File

@@ -20,12 +20,10 @@ def execute():
)
frappe.db.sql(
"""UPDATE `tabTimesheet`
SET currency = '{0}',
f"""UPDATE `tabTimesheet`
SET currency = '{base_currency}',
exchange_rate = 1.0,
base_total_billable_amount = total_billable_amount,
base_total_billed_amount = total_billed_amount,
base_total_costing_amount = total_costing_amount""".format(
base_currency
)
base_total_costing_amount = total_costing_amount"""
)

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
doctype = "Stock Reconciliation Item"
if not frappe.db.has_column(doctype, "current_serial_no"):
@@ -11,6 +10,4 @@ def execute():
sr_item = frappe.qb.DocType(doctype)
(
frappe.qb.update(sr_item).set(sr_item.current_serial_no, None).where(sr_item.current_qty == 0)
).run()
(frappe.qb.update(sr_item).set(sr_item.current_serial_no, None).where(sr_item.current_qty == 0)).run()

View File

@@ -7,20 +7,16 @@ import frappe
def execute():
for doctype in ["Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation"]:
frappe.db.sql(
"""
f"""
UPDATE `tab{doctype}`
SET is_subcontracted = 0
where is_subcontracted in ('', 'No') or is_subcontracted is null""".format(
doctype=doctype
)
where is_subcontracted in ('', 'No') or is_subcontracted is null"""
)
frappe.db.sql(
"""
f"""
UPDATE `tab{doctype}`
SET is_subcontracted = 1
where is_subcontracted = 'Yes'""".format(
doctype=doctype
)
where is_subcontracted = 'Yes'"""
)
frappe.reload_doc(frappe.get_meta(doctype).module, "doctype", frappe.scrub(doctype))

View File

@@ -7,6 +7,4 @@ import frappe
def execute():
for doctype in ["Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
tab = frappe.qb.DocType(doctype).as_("tab")
frappe.qb.update(tab).set(tab.is_old_subcontracting_flow, 1).where(
tab.is_subcontracted == 1
).run()
frappe.qb.update(tab).set(tab.is_old_subcontracting_flow, 1).where(tab.is_subcontracted == 1).run()

View File

@@ -39,9 +39,7 @@ def correct_value_for_assets_with_manual_depr_entries():
asset.opening_accumulated_depreciation.as_("opening_accumulated_depreciation"),
Sum(gle.debit).as_("depr_amount"),
)
.where(
gle.account == IfNull(aca.depreciation_expense_account, company.depreciation_expense_account)
)
.where(gle.account == IfNull(aca.depreciation_expense_account, company.depreciation_expense_account))
.where(gle.debit != 0)
.where(gle.is_cancelled == 0)
.where(asset.docstatus == 1)
@@ -80,9 +78,7 @@ def correct_value_for_assets_with_auto_depr(fb_name=None):
asset.opening_accumulated_depreciation.as_("opening_accumulated_depreciation"),
Sum(gle.debit).as_("depr_amount"),
)
.where(
gle.account == IfNull(aca.depreciation_expense_account, company.depreciation_expense_account)
)
.where(gle.account == IfNull(aca.depreciation_expense_account, company.depreciation_expense_account))
.where(gle.debit != 0)
.where(gle.is_cancelled == 0)
.where(asset.docstatus == 1)

View File

@@ -12,7 +12,6 @@ def execute():
count = 1
for d in accounting_dimensions:
if count % 2 == 0:
insert_after_field = "dimension_col_break"
else:
@@ -24,7 +23,6 @@ def execute():
"Subcontracting Receipt",
"Subcontracting Receipt Item",
]:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
if field:

View File

@@ -45,7 +45,8 @@ def add_calendar_event_for_leads():
"owner": d.lead_owner,
"subject": ("Contact " + cstr(d.lead_name)),
"description": (
("Contact " + cstr(d.lead_name)) + (("<br>By: " + cstr(d.contact_by)) if d.contact_by else "")
("Contact " + cstr(d.lead_name))
+ (("<br>By: " + cstr(d.contact_by)) if d.contact_by else "")
),
"starts_on": d.contact_date,
"ends_on": d.ends_on,
@@ -87,8 +88,6 @@ def add_calendar_event_for_opportunities():
}
)
event.append(
"event_participants", {"reference_doctype": "Opportunity", "reference_docname": d.name}
)
event.append("event_participants", {"reference_doctype": "Opportunity", "reference_docname": d.name})
event.insert(ignore_permissions=True)

View File

@@ -13,9 +13,7 @@ def execute():
for report in reports:
frappe.delete_doc("Report", report, ignore_missing=True, force=True)
dashboards = frappe.get_all(
"Dashboard", {"module": "agriculture", "is_standard": 1}, pluck="name"
)
dashboards = frappe.get_all("Dashboard", {"module": "agriculture", "is_standard": 1}, pluck="name")
for dashboard in dashboards:
frappe.delete_doc("Dashboard", dashboard, ignore_missing=True, force=True)

View File

@@ -16,9 +16,7 @@ def execute():
for report in reports:
frappe.delete_doc("Report", report, ignore_missing=True, force=True)
print_formats = frappe.get_all(
"Print Format", {"module": "education", "standard": "Yes"}, pluck="name"
)
print_formats = frappe.get_all("Print Format", {"module": "education", "standard": "Yes"}, pluck="name")
for print_format in print_formats:
frappe.delete_doc("Print Format", print_format, ignore_missing=True, force=True)
@@ -31,9 +29,7 @@ def execute():
for dashboard in dashboards:
frappe.delete_doc("Dashboard", dashboard, ignore_missing=True, force=True)
dashboards = frappe.get_all(
"Dashboard Chart", {"module": "education", "is_standard": 1}, pluck="name"
)
dashboards = frappe.get_all("Dashboard Chart", {"module": "education", "is_standard": 1}, pluck="name")
for dashboard in dashboards:
frappe.delete_doc("Dashboard Chart", dashboard, ignore_missing=True, force=True)

View File

@@ -15,9 +15,7 @@ def execute():
for report in reports:
frappe.delete_doc("Report", report, ignore_missing=True, force=True)
print_formats = frappe.get_all(
"Print Format", {"module": "healthcare", "standard": "Yes"}, pluck="name"
)
print_formats = frappe.get_all("Print Format", {"module": "healthcare", "standard": "Yes"}, pluck="name")
for print_format in print_formats:
frappe.delete_doc("Print Format", print_format, ignore_missing=True, force=True)
@@ -30,9 +28,7 @@ def execute():
for dashboard in dashboards:
frappe.delete_doc("Dashboard", dashboard, ignore_missing=True, force=True)
dashboards = frappe.get_all(
"Dashboard Chart", {"module": "healthcare", "is_standard": 1}, pluck="name"
)
dashboards = frappe.get_all("Dashboard Chart", {"module": "healthcare", "is_standard": 1}, pluck="name")
for dashboard in dashboards:
frappe.delete_doc("Dashboard Chart", dashboard, ignore_missing=True, force=True)

View File

@@ -2,7 +2,6 @@ import frappe
def execute():
doctypes = frappe.get_all("DocType", {"module": "Hub Node", "custom": 0}, pluck="name")
for doctype in doctypes:
frappe.delete_doc("DocType", doctype, ignore_missing=True)

View File

@@ -6,9 +6,7 @@ def execute():
frappe.delete_doc("Workspace", "Non Profit", ignore_missing=True, force=True)
print_formats = frappe.get_all(
"Print Format", {"module": "Non Profit", "standard": "Yes"}, pluck="name"
)
print_formats = frappe.get_all("Print Format", {"module": "Non Profit", "standard": "Yes"}, pluck="name")
for print_format in print_formats:
frappe.delete_doc("Print Format", print_format, ignore_missing=True, force=True)

View File

@@ -15,12 +15,10 @@ def execute():
frappe.reload_doctype(doctype)
for key, value in options.items():
frappe.db.sql(
"""
f"""
update `tab{doctype}`
set no_of_employees = %s
where no_of_employees = %s
""".format(
doctype=doctype
),
""",
(value, key),
)

View File

@@ -44,8 +44,6 @@ def get_existing_cost_center_allocations():
cc_allocations = frappe._dict()
for d in records:
cc_allocations.setdefault(d.name, frappe._dict()).setdefault(
d.cost_center, d.percentage_allocation
)
cc_allocations.setdefault(d.name, frappe._dict()).setdefault(d.cost_center, d.percentage_allocation)
return cc_allocations

View File

@@ -152,7 +152,8 @@ def execute():
gl.star,
ConstantColumn(1).as_("docstatus"),
IfNull(
ifelse(gl.against_voucher_type == "", None, gl.against_voucher_type), gl.voucher_type
ifelse(gl.against_voucher_type == "", None, gl.against_voucher_type),
gl.voucher_type,
).as_("against_voucher_type"),
IfNull(ifelse(gl.against_voucher == "", None, gl.against_voucher), gl.voucher_no).as_(
"against_voucher_no"

Some files were not shown because too many files have changed in this diff Show More