refactor(treewide): formatting and ruff fixes, + manually enabled F401
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 9d86cb2..89e47b4 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -20,13 +20,13 @@
self.flags.ignore_permlevel_for_fields = ["selling_price_list", "price_list_currency"]
def onload(self):
- super(SellingController, self).onload()
+ super().onload()
if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice"):
for item in self.get("items") + (self.get("packed_items") or []):
item.update(get_bin_details(item.item_code, item.warehouse, include_child_warehouses=True))
def validate(self):
- super(SellingController, self).validate()
+ super().validate()
self.validate_items()
if not self.get("is_debit_note"):
self.validate_max_discount()
@@ -44,7 +44,7 @@
self.set_serial_and_batch_bundle(table_field)
def set_missing_values(self, for_validate=False):
- super(SellingController, self).set_missing_values(for_validate)
+ super().set_missing_values(for_validate)
# set contact and address details for customer, if they are not mentioned
self.set_missing_lead_customer_details(for_validate=for_validate)
@@ -290,7 +290,10 @@
if flt(item.base_net_rate) < flt(last_valuation_rate_in_sales_uom):
throw_message(
- item.idx, item.item_name, last_valuation_rate_in_sales_uom, "valuation rate (Moving Average)"
+ item.idx,
+ item.item_name,
+ last_valuation_rate_in_sales_uom,
+ "valuation rate (Moving Average)",
)
def get_item_list(self):
@@ -419,7 +422,8 @@
"Cancelled"
]:
frappe.throw(
- _("{0} {1} is cancelled or closed").format(_("Sales Order"), so), frappe.InvalidStatusError
+ _("{0} {1} is cancelled or closed").format(_("Sales Order"), so),
+ frappe.InvalidStatusError,
)
sales_order.update_reserved_qty(so_item_rows)
@@ -623,7 +627,8 @@
if self.doctype in ["Sales Order", "Quotation"]:
for item in self.items:
item.gross_profit = flt(
- ((item.base_rate - flt(item.valuation_rate)) * item.stock_qty), self.precision("amount", item)
+ ((item.base_rate - flt(item.valuation_rate)) * item.stock_qty),
+ self.precision("amount", item),
)
def set_customer_address(self):
@@ -700,9 +705,9 @@
if d.get("target_warehouse") and d.get("warehouse") == d.get("target_warehouse"):
warehouse = frappe.bold(d.get("target_warehouse"))
frappe.throw(
- _("Row {0}: Delivery Warehouse ({1}) and Customer Warehouse ({2}) can not be same").format(
- d.idx, warehouse, warehouse
- )
+ _(
+ "Row {0}: Delivery Warehouse ({1}) and Customer Warehouse ({2}) can not be same"
+ ).format(d.idx, warehouse, warehouse)
)
if not self.get("is_internal_customer") and any(d.get("target_warehouse") for d in items):
@@ -730,14 +735,10 @@
if child.get("use_serial_batch_fields"):
return
- if not frappe.db.get_single_value(
- "Stock Settings", "auto_create_serial_and_batch_bundle_for_outward"
- ):
+ if not frappe.db.get_single_value("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward"):
return
- item_details = frappe.db.get_value(
- "Item", child.item_code, ["has_serial_no", "has_batch_no"], as_dict=1
- )
+ item_details = frappe.db.get_value("Item", child.item_code, ["has_serial_no", "has_batch_no"], as_dict=1)
if not item_details.has_serial_no and not item_details.has_batch_no:
return