mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
refactor(treewide): formatting and ruff fixes, + manually enabled F401
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
@@ -15,7 +15,7 @@ from erpnext.stock.utils import get_bin
|
||||
|
||||
class SubcontractingOrder(SubcontractingController):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubcontractingOrder, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.status_updater = [
|
||||
{
|
||||
@@ -32,10 +32,10 @@ class SubcontractingOrder(SubcontractingController):
|
||||
]
|
||||
|
||||
def before_validate(self):
|
||||
super(SubcontractingOrder, self).before_validate()
|
||||
super().before_validate()
|
||||
|
||||
def validate(self):
|
||||
super(SubcontractingOrder, self).validate()
|
||||
super().validate()
|
||||
self.validate_purchase_order_for_subcontracting()
|
||||
self.validate_items()
|
||||
self.validate_service_items()
|
||||
@@ -136,9 +136,7 @@ class SubcontractingOrder(SubcontractingController):
|
||||
):
|
||||
item_wh_list.append([item.item_code, item.warehouse])
|
||||
for item_code, warehouse in item_wh_list:
|
||||
update_bin_qty(
|
||||
item_code, warehouse, {"ordered_qty": self.get_ordered_qty(item_code, warehouse)}
|
||||
)
|
||||
update_bin_qty(item_code, warehouse, {"ordered_qty": self.get_ordered_qty(item_code, warehouse)})
|
||||
|
||||
@staticmethod
|
||||
def get_ordered_qty(item_code, warehouse):
|
||||
@@ -212,7 +210,10 @@ class SubcontractingOrder(SubcontractingController):
|
||||
elif self.per_received > 0 and self.per_received < 100:
|
||||
status = "Partially Received"
|
||||
for item in self.supplied_items:
|
||||
if not item.returned_qty or (item.supplied_qty - item.consumed_qty - item.returned_qty) > 0:
|
||||
if (
|
||||
not item.returned_qty
|
||||
or (item.supplied_qty - item.consumed_qty - item.returned_qty) > 0
|
||||
):
|
||||
break
|
||||
else:
|
||||
status = "Closed"
|
||||
|
||||
@@ -211,7 +211,7 @@ class TestSubcontractingOrder(FrappeTestCase):
|
||||
item["qty"] -= 1
|
||||
itemwise_transfer_qty[item["item_code"]] += item["qty"]
|
||||
|
||||
ste = make_stock_transfer_entry(
|
||||
make_stock_transfer_entry(
|
||||
sco_no=sco.name,
|
||||
rm_items=rm_items,
|
||||
itemwise_details=copy.deepcopy(itemwise_details),
|
||||
|
||||
@@ -12,7 +12,7 @@ from erpnext.controllers.subcontracting_controller import SubcontractingControll
|
||||
|
||||
class SubcontractingReceipt(SubcontractingController):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubcontractingReceipt, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.status_updater = [
|
||||
{
|
||||
"target_dt": "Subcontracting Order Item",
|
||||
@@ -31,9 +31,7 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
def onload(self):
|
||||
self.set_onload(
|
||||
"backflush_based_on",
|
||||
frappe.db.get_single_value(
|
||||
"Buying Settings", "backflush_raw_materials_of_subcontract_based_on"
|
||||
),
|
||||
frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on"),
|
||||
)
|
||||
|
||||
def update_status_updater_args(self):
|
||||
@@ -64,7 +62,7 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
)
|
||||
|
||||
def before_validate(self):
|
||||
super(SubcontractingReceipt, self).before_validate()
|
||||
super().before_validate()
|
||||
self.validate_items_qty()
|
||||
self.set_items_bom()
|
||||
self.set_items_cost_center()
|
||||
@@ -77,7 +75,7 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
) and not self.has_serial_batch_items():
|
||||
self.supplied_items = []
|
||||
|
||||
super(SubcontractingReceipt, self).validate()
|
||||
super().validate()
|
||||
self.set_missing_values()
|
||||
self.validate_posting_time()
|
||||
self.validate_rejected_warehouse()
|
||||
@@ -144,7 +142,9 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
.select(
|
||||
sco_supplied_item.rm_item_code,
|
||||
sco_supplied_item.reference_name,
|
||||
(sco_supplied_item.total_supplied_qty - sco_supplied_item.consumed_qty).as_("available_qty"),
|
||||
(sco_supplied_item.total_supplied_qty - sco_supplied_item.consumed_qty).as_(
|
||||
"available_qty"
|
||||
),
|
||||
)
|
||||
.where(
|
||||
(sco_supplied_item.parent == item.subcontracting_order)
|
||||
@@ -157,7 +157,9 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
supplied_items_details[item.name] = {}
|
||||
|
||||
for supplied_item in supplied_items:
|
||||
supplied_items_details[item.name][supplied_item.rm_item_code] = supplied_item.available_qty
|
||||
supplied_items_details[item.name][
|
||||
supplied_item.rm_item_code
|
||||
] = supplied_item.available_qty
|
||||
else:
|
||||
for item in self.get("supplied_items"):
|
||||
item.available_qty_for_consumption = supplied_items_details.get(item.reference_name, {}).get(
|
||||
@@ -233,7 +235,9 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
for item in self.items:
|
||||
if not (item.qty or item.rejected_qty):
|
||||
frappe.throw(
|
||||
_("Row {0}: Accepted Qty and Rejected Qty can't be zero at the same time.").format(item.idx)
|
||||
_("Row {0}: Accepted Qty and Rejected Qty can't be zero at the same time.").format(
|
||||
item.idx
|
||||
)
|
||||
)
|
||||
|
||||
def set_items_bom(self):
|
||||
@@ -328,10 +332,12 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
|
||||
warehouse_account_name = warehouse_account[item.warehouse]["account"]
|
||||
warehouse_account_currency = warehouse_account[item.warehouse]["account_currency"]
|
||||
supplier_warehouse_account = warehouse_account.get(self.supplier_warehouse, {}).get("account")
|
||||
supplier_warehouse_account_currency = warehouse_account.get(self.supplier_warehouse, {}).get(
|
||||
"account_currency"
|
||||
supplier_warehouse_account = warehouse_account.get(self.supplier_warehouse, {}).get(
|
||||
"account"
|
||||
)
|
||||
supplier_warehouse_account_currency = warehouse_account.get(
|
||||
self.supplier_warehouse, {}
|
||||
).get("account_currency")
|
||||
remarks = self.get("remarks") or _("Accounting Entry for Stock")
|
||||
|
||||
# FG Warehouse Account (Debit)
|
||||
|
||||
@@ -6,7 +6,7 @@ import copy
|
||||
|
||||
import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.utils import add_days, cint, cstr, flt, today
|
||||
from frappe.utils import add_days, cint, flt, today
|
||||
|
||||
import erpnext
|
||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||
@@ -43,9 +43,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
|
||||
def test_subcontracting(self):
|
||||
set_backflush_based_on("BOM")
|
||||
make_stock_entry(
|
||||
item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100
|
||||
)
|
||||
make_stock_entry(item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100",
|
||||
qty=100,
|
||||
@@ -77,9 +75,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
self.assertEqual(scr.get("items")[0].rm_supp_cost, flt(rm_supp_cost))
|
||||
|
||||
def test_available_qty_for_consumption(self):
|
||||
make_stock_entry(
|
||||
item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100
|
||||
)
|
||||
make_stock_entry(item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100",
|
||||
qty=100,
|
||||
@@ -206,12 +202,8 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
make_stock_entry(
|
||||
target="_Test Warehouse - _TC", item_code="Test Extra Item 1", qty=10, basic_rate=100
|
||||
)
|
||||
make_stock_entry(
|
||||
target="_Test Warehouse - _TC", item_code="_Test FG Item", qty=1, basic_rate=100
|
||||
)
|
||||
make_stock_entry(
|
||||
target="_Test Warehouse - _TC", item_code="Test Extra Item 2", qty=1, basic_rate=100
|
||||
)
|
||||
make_stock_entry(target="_Test Warehouse - _TC", item_code="_Test FG Item", qty=1, basic_rate=100)
|
||||
make_stock_entry(target="_Test Warehouse - _TC", item_code="Test Extra Item 2", qty=1, basic_rate=100)
|
||||
|
||||
rm_items = [
|
||||
{
|
||||
@@ -476,9 +468,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
set_backflush_based_on("Material Transferred for Subcontract")
|
||||
|
||||
# Create Material Receipt for RM's
|
||||
make_stock_entry(
|
||||
item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100
|
||||
)
|
||||
make_stock_entry(item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100",
|
||||
qty=100,
|
||||
@@ -732,9 +722,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
def make_return_subcontracting_receipt(**args):
|
||||
args = frappe._dict(args)
|
||||
return_doc = make_return_doc("Subcontracting Receipt", args.scr_name)
|
||||
return_doc.supplier_warehouse = (
|
||||
args.supplier_warehouse or args.warehouse or "_Test Warehouse 1 - _TC"
|
||||
)
|
||||
return_doc.supplier_warehouse = args.supplier_warehouse or args.warehouse or "_Test Warehouse 1 - _TC"
|
||||
|
||||
if args.qty:
|
||||
for item in return_doc.items:
|
||||
|
||||
Reference in New Issue
Block a user