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 8afb7790de
commit 3effaf21ef
574 changed files with 4135 additions and 6276 deletions

View File

@@ -20,13 +20,13 @@ class SellingController(StockController):
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 @@ class SellingController(StockController):
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 @@ class SellingController(StockController):
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 @@ class SellingController(StockController):
"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 @@ class SellingController(StockController):
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 @@ class SellingController(StockController):
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 @@ def get_serial_and_batch_bundle(child, parent):
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