fix(treewide): manual ruff fixes
(cherry picked from commitf63396ef47) (cherry picked from commit7828eee014) Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
@@ -253,7 +253,7 @@ def make_charts():
|
||||
for key, val in chart["tree"].items():
|
||||
if key in ["name", "parent_id"]:
|
||||
chart["tree"].pop(key)
|
||||
if type(val) == dict:
|
||||
if isinstance(val, dict):
|
||||
val["root_type"] = ""
|
||||
if chart:
|
||||
fpath = os.path.join(
|
||||
|
||||
@@ -14,26 +14,6 @@ from frappe.utils.data import guess_date_format
|
||||
|
||||
|
||||
class BisectAccountingStatements(Document):
|
||||
# begin: auto-generated types
|
||||
# This code is auto-generated. Do not modify anything in this block.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from frappe.types import DF
|
||||
|
||||
algorithm: DF.Literal["BFS", "DFS"]
|
||||
b_s_summary: DF.Float
|
||||
company: DF.Link | None
|
||||
current_from_date: DF.Datetime | None
|
||||
current_node: DF.Link | None
|
||||
current_to_date: DF.Datetime | None
|
||||
difference: DF.Float
|
||||
from_date: DF.Datetime | None
|
||||
p_l_summary: DF.Float
|
||||
to_date: DF.Datetime | None
|
||||
# end: auto-generated types
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
|
||||
|
||||
@@ -348,12 +348,9 @@ def get_actual_expense(args):
|
||||
|
||||
args.update(lft_rgt)
|
||||
|
||||
condition2 = """and exists(select name from `tab{doctype}`
|
||||
condition2 = f"""and exists(select name from `tab{args.budget_against_doctype}`
|
||||
where lft>=%(lft)s and rgt<=%(rgt)s
|
||||
and name=gle.{budget_against_field})""".format(
|
||||
doctype=args.budget_against_doctype,
|
||||
budget_against_field=budget_against_field, # nosec
|
||||
)
|
||||
and name=gle.{budget_against_field})"""
|
||||
else:
|
||||
condition2 = f"""and exists(select name from `tab{args.budget_against_doctype}`
|
||||
where name=gle.{budget_against_field} and
|
||||
|
||||
@@ -75,8 +75,8 @@ class TestInvoiceDiscounting(unittest.TestCase):
|
||||
gle = get_gl_entries("Invoice Discounting", inv_disc.name)
|
||||
|
||||
expected_gle = {inv.debit_to: [0.0, 200], self.ar_credit: [200, 0.0]}
|
||||
for _i, gle in enumerate(gle):
|
||||
self.assertEqual([gle.debit, gle.credit], expected_gle.get(gle.account))
|
||||
for _i, gle_value in enumerate(gle):
|
||||
self.assertEqual([gle_value.debit, gle_value.credit], expected_gle.get(gle_value.account))
|
||||
|
||||
def test_loan_on_submit(self):
|
||||
inv = create_sales_invoice(rate=300)
|
||||
|
||||
@@ -162,7 +162,7 @@ class TestPaymentEntry(FrappeTestCase):
|
||||
|
||||
supplier.on_hold = 0
|
||||
supplier.save()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
@@ -84,11 +84,14 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
||||
self.customer = customer.name
|
||||
|
||||
def create_sales_invoice(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
sinv = create_sales_invoice(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
@@ -112,10 +115,12 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
||||
)
|
||||
return sinv
|
||||
|
||||
def create_payment_entry(self, amount=100, posting_date=nowdate()):
|
||||
def create_payment_entry(self, amount=100, posting_date=None):
|
||||
"""
|
||||
Helper function to populate default values in payment entry
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
payment = create_payment_entry(
|
||||
company=self.company,
|
||||
payment_type="Receive",
|
||||
@@ -128,9 +133,10 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
||||
payment.posting_date = posting_date
|
||||
return payment
|
||||
|
||||
def create_sales_order(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
):
|
||||
def create_sales_order(self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False):
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
so = make_sales_order(
|
||||
company=self.company,
|
||||
transaction_date=posting_date,
|
||||
|
||||
@@ -126,11 +126,14 @@ class TestPaymentReconciliation(FrappeTestCase):
|
||||
setattr(self, x.attribute, acc.name)
|
||||
|
||||
def create_sales_invoice(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
sinv = create_sales_invoice(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
@@ -154,10 +157,13 @@ class TestPaymentReconciliation(FrappeTestCase):
|
||||
)
|
||||
return sinv
|
||||
|
||||
def create_payment_entry(self, amount=100, posting_date=nowdate(), customer=None):
|
||||
def create_payment_entry(self, amount=100, posting_date=None, customer=None):
|
||||
"""
|
||||
Helper function to populate default values in payment entry
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
payment = create_payment_entry(
|
||||
company=self.company,
|
||||
payment_type="Receive",
|
||||
@@ -171,11 +177,14 @@ class TestPaymentReconciliation(FrappeTestCase):
|
||||
return payment
|
||||
|
||||
def create_purchase_invoice(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
pinv = make_purchase_invoice(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
@@ -200,11 +209,14 @@ class TestPaymentReconciliation(FrappeTestCase):
|
||||
return pinv
|
||||
|
||||
def create_purchase_order(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
pord = create_purchase_order(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
|
||||
@@ -440,7 +440,7 @@ def create_merge_logs(invoice_by_customer, closing_entry=None):
|
||||
|
||||
if closing_entry:
|
||||
closing_entry.set_status(update=True, status="Failed")
|
||||
if type(error_message) == list:
|
||||
if isinstance(error_message, list):
|
||||
error_message = frappe.json.dumps(error_message)
|
||||
closing_entry.db_set("error_message", error_message)
|
||||
raise
|
||||
|
||||
@@ -478,7 +478,7 @@ def reconcile(doc: None | str = None) -> None:
|
||||
def is_any_doc_running(for_filter: str | dict | None = None) -> str | None:
|
||||
running_doc = None
|
||||
if for_filter:
|
||||
if type(for_filter) == str:
|
||||
if isinstance(for_filter, str):
|
||||
for_filter = frappe.json.loads(for_filter)
|
||||
|
||||
running_doc = frappe.db.get_value(
|
||||
|
||||
@@ -216,7 +216,7 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin):
|
||||
|
||||
supplier.on_hold = 0
|
||||
supplier.save()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
@@ -3521,41 +3521,6 @@ class TestSalesInvoice(FrappeTestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
def get_sales_invoice_for_e_invoice():
|
||||
si = make_sales_invoice_for_ewaybill()
|
||||
si.naming_series = "INV-2020-.#####"
|
||||
si.items = []
|
||||
si.append(
|
||||
"items",
|
||||
{
|
||||
"item_code": "_Test Item",
|
||||
"uom": "Nos",
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"qty": 2000,
|
||||
"rate": 12,
|
||||
"income_account": "Sales - _TC",
|
||||
"expense_account": "Cost of Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
)
|
||||
|
||||
si.append(
|
||||
"items",
|
||||
{
|
||||
"item_code": "_Test Item 2",
|
||||
"uom": "Nos",
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"qty": 420,
|
||||
"rate": 15,
|
||||
"income_account": "Sales - _TC",
|
||||
"expense_account": "Cost of Goods Sold - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
)
|
||||
|
||||
return si
|
||||
|
||||
|
||||
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
||||
gl_entries = frappe.db.sql(
|
||||
"""select account, debit, credit, posting_date
|
||||
|
||||
@@ -473,7 +473,7 @@ def execute(filters=None):
|
||||
|
||||
|
||||
def _get_account_type_based_data(filters, account_names, period_list, accumulated_values, opening_balances=0):
|
||||
if not account_names or not account_names[0] or not type(account_names[0]) == str:
|
||||
if not account_names or not account_names[0] or not isinstance(account_names[0], str):
|
||||
# only proceed if account_names is a list of account names
|
||||
return {}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ class Deferred_Invoice:
|
||||
for item in self.items:
|
||||
item_total = item.calculate_item_revenue_expense_for_period()
|
||||
# update invoice total
|
||||
for idx, period in enumerate(self.period_list, 0):
|
||||
for idx in range(len(self.period_list)):
|
||||
self.period_total[idx].total += item_total[idx].total
|
||||
self.period_total[idx].actual += item_total[idx].actual
|
||||
return self.period_total
|
||||
@@ -346,7 +346,7 @@ class Deferred_Revenue_and_Expense_Report:
|
||||
for inv in self.deferred_invoices:
|
||||
inv_total = inv.calculate_invoice_revenue_expense_for_period()
|
||||
# calculate total for whole report
|
||||
for idx, period in enumerate(self.period_list, 0):
|
||||
for idx in range(len(self.period_list)):
|
||||
self.period_total[idx].total += inv_total[idx].total
|
||||
self.period_total[idx].actual += inv_total[idx].actual
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
||||
else:
|
||||
update_value_in_dict(consolidated_gle, key, gle)
|
||||
|
||||
for key, value in consolidated_gle.items():
|
||||
for value in consolidated_gle.values():
|
||||
update_value_in_dict(totals, "total", value)
|
||||
update_value_in_dict(totals, "closing", value)
|
||||
entries.append(value)
|
||||
|
||||
@@ -494,7 +494,7 @@ class GrossProfitGenerator:
|
||||
def get_average_rate_based_on_group_by(self):
|
||||
for key in list(self.grouped):
|
||||
if self.filters.get("group_by") == "Invoice":
|
||||
for i, row in enumerate(self.grouped[key]):
|
||||
for row in self.grouped[key]:
|
||||
if row.indent == 1.0:
|
||||
if (
|
||||
row.parent in self.returned_invoices
|
||||
|
||||
@@ -86,11 +86,14 @@ class TestGrossProfit(FrappeTestCase):
|
||||
self.customer = customer.name
|
||||
|
||||
def create_sales_invoice(
|
||||
self, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
sinv = create_sales_invoice(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
@@ -115,11 +118,14 @@ class TestGrossProfit(FrappeTestCase):
|
||||
return sinv
|
||||
|
||||
def create_delivery_note(
|
||||
self, item=None, qty=1, rate=100, posting_date=nowdate(), do_not_save=False, do_not_submit=False
|
||||
self, item=None, qty=1, rate=100, posting_date=None, do_not_save=False, do_not_submit=False
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in Delivery Note
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
dnote = create_delivery_note(
|
||||
company=self.company,
|
||||
customer=self.customer,
|
||||
|
||||
@@ -692,7 +692,7 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
|
||||
supplier.on_hold = 0
|
||||
supplier.save()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestProcurementTracker(FrappeTestCase):
|
||||
pass
|
||||
@@ -140,13 +140,16 @@ class TestAccountsController(FrappeTestCase):
|
||||
qty=1,
|
||||
rate=1,
|
||||
conversion_rate=80,
|
||||
posting_date=nowdate(),
|
||||
posting_date=None,
|
||||
do_not_save=False,
|
||||
do_not_submit=False,
|
||||
):
|
||||
"""
|
||||
Helper function to populate default values in sales invoice
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
sinv = create_sales_invoice(
|
||||
qty=qty,
|
||||
rate=rate,
|
||||
@@ -171,10 +174,13 @@ class TestAccountsController(FrappeTestCase):
|
||||
)
|
||||
return sinv
|
||||
|
||||
def create_payment_entry(self, amount=1, source_exc_rate=75, posting_date=nowdate(), customer=None):
|
||||
def create_payment_entry(self, amount=1, source_exc_rate=75, posting_date=None, customer=None):
|
||||
"""
|
||||
Helper function to populate default values in payment entry
|
||||
"""
|
||||
if posting_date is None:
|
||||
posting_date = nowdate()
|
||||
|
||||
payment = create_payment_entry(
|
||||
company=self.company,
|
||||
payment_type="Receive",
|
||||
|
||||
@@ -551,7 +551,7 @@ class TestSubcontractingController(FrappeTestCase):
|
||||
scr2.set_missing_values()
|
||||
scr2.submit()
|
||||
|
||||
for key, value in get_supplied_items(scr2).items():
|
||||
for value in get_supplied_items(scr2).values():
|
||||
self.assertEqual(value.qty, 4)
|
||||
|
||||
scr3 = make_subcontracting_receipt(sco.name)
|
||||
@@ -561,7 +561,7 @@ class TestSubcontractingController(FrappeTestCase):
|
||||
scr3.set_missing_values()
|
||||
scr3.submit()
|
||||
|
||||
for key, value in get_supplied_items(scr3).items():
|
||||
for value in get_supplied_items(scr3).values():
|
||||
self.assertEqual(value.qty, 1)
|
||||
|
||||
def test_partial_transfer_serial_no_components_based_on_material_transfer(self):
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
import datetime
|
||||
import typing
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
@@ -10,7 +11,7 @@ from frappe.model.document import Document
|
||||
|
||||
|
||||
class AppointmentBookingSettings(Document):
|
||||
agent_list = [] # Hack
|
||||
agent_list: typing.ClassVar[list] = [] # Hack
|
||||
min_date = "01/01/1970 "
|
||||
format_string = "%d/%m/%Y %H:%M:%S"
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class ItemVariantsCacheManager:
|
||||
item_attribute_value_map.setdefault(item_code, {})[attribute] = attribute_value
|
||||
|
||||
optional_attributes = set()
|
||||
for item_code, attr_dict in item_attribute_value_map.items():
|
||||
for attr_dict in item_attribute_value_map.values():
|
||||
for attribute in attributes:
|
||||
if attribute not in attr_dict:
|
||||
optional_attributes.add(attribute)
|
||||
|
||||
@@ -80,7 +80,7 @@ def get_attributes_and_values(item_code):
|
||||
attribute_list = [a.attribute for a in attributes]
|
||||
|
||||
valid_options = {}
|
||||
for item_code, attribute, attribute_value in item_variants_data:
|
||||
for _, attribute, attribute_value in item_variants_data:
|
||||
if attribute in attribute_list:
|
||||
valid_options.setdefault(attribute, set()).add(attribute_value)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
import typing
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import frappe
|
||||
@@ -15,7 +16,7 @@ from erpnext.utilities import payment_app_import_guard
|
||||
|
||||
|
||||
class GoCardlessSettings(Document):
|
||||
supported_currencies = ["EUR", "DKK", "GBP", "SEK", "AUD", "NZD", "CAD", "USD"]
|
||||
supported_currencies: typing.ClassVar[list] = ["EUR", "DKK", "GBP", "SEK", "AUD", "NZD", "CAD", "USD"]
|
||||
|
||||
def validate(self):
|
||||
self.initialize_client()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
import typing
|
||||
from json import dumps, loads
|
||||
|
||||
import frappe
|
||||
@@ -19,7 +20,7 @@ from erpnext.utilities import payment_app_import_guard
|
||||
|
||||
|
||||
class MpesaSettings(Document):
|
||||
supported_currencies = ["KES"]
|
||||
supported_currencies: typing.ClassVar[list] = ["KES"]
|
||||
|
||||
def validate_transaction_currency(self, currency):
|
||||
if currency not in self.supported_currencies:
|
||||
|
||||
@@ -1503,7 +1503,7 @@ def get_items_for_material_requests(doc, warehouses=None, get_parent_warehouse_d
|
||||
so_item_details[sales_order][item_code] = details
|
||||
|
||||
mr_items = []
|
||||
for sales_order, item_code in so_item_details.items():
|
||||
for sales_order in so_item_details:
|
||||
item_dict = so_item_details[sales_order]
|
||||
for details in item_dict.values():
|
||||
bin_dict = get_bin_details(details, doc.company, warehouse)
|
||||
|
||||
@@ -87,7 +87,7 @@ class ForecastingReport(ExponentialSmoothingForecast):
|
||||
entry.get(self.based_on_field)
|
||||
)
|
||||
|
||||
for key, value in self.period_wise_data.items():
|
||||
for value in self.period_wise_data.values():
|
||||
list_of_period_value = [value.get(p.key, 0) for p in self.period_list]
|
||||
|
||||
if list_of_period_value:
|
||||
|
||||
@@ -8,13 +8,11 @@ def execute():
|
||||
frappe.reload_doc("accounts", "doctype", frappe.scrub(doctype))
|
||||
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabGL Entry`, `tab{doctype}`
|
||||
f""" UPDATE `tabGL Entry`, `tab{doctype}`
|
||||
SET
|
||||
`tabGL Entry`.due_date = `tab{doctype}`.due_date
|
||||
WHERE
|
||||
`tabGL Entry`.voucher_no = `tab{doctype}`.name and `tabGL Entry`.party is not null
|
||||
and `tabGL Entry`.voucher_type in ('Sales Invoice', 'Purchase Invoice', 'Journal Entry')
|
||||
and `tabGL Entry`.account in (select name from `tabAccount` where account_type in ('Receivable', 'Payable'))""".format( # nosec
|
||||
doctype=doctype
|
||||
)
|
||||
and `tabGL Entry`.account in (select name from `tabAccount` where account_type in ('Receivable', 'Payable'))"""
|
||||
)
|
||||
|
||||
@@ -100,7 +100,7 @@ def get_opp_by_lead_source(from_date, to_date, company):
|
||||
pivot_table = []
|
||||
for sales_stage in sales_stages:
|
||||
row = []
|
||||
for source, sales_stage_values in summary.items():
|
||||
for sales_stage_values in summary.values():
|
||||
row.append(flt(sales_stage_values.get(sales_stage)))
|
||||
pivot_table.append({"chartType": "bar", "name": sales_stage, "values": row})
|
||||
|
||||
|
||||
@@ -112,7 +112,13 @@ class TestHolidayList(unittest.TestCase):
|
||||
frappe.local.lang = lang
|
||||
|
||||
|
||||
def make_holiday_list(name, from_date=getdate() - timedelta(days=10), to_date=getdate(), holiday_dates=None):
|
||||
def make_holiday_list(name, from_date=None, to_date=None, holiday_dates=None):
|
||||
if from_date is None:
|
||||
from_date = getdate() - timedelta(days=10)
|
||||
|
||||
if to_date is None:
|
||||
to_date = getdate()
|
||||
|
||||
frappe.delete_doc_if_exists("Holiday List", name, force=1)
|
||||
doc = frappe.get_doc(
|
||||
{
|
||||
|
||||
@@ -456,12 +456,7 @@ def is_deletion_doc_running(company: str | None = None, err_msg: str | None = No
|
||||
def check_for_running_deletion_job(doc, method=None):
|
||||
# Check if DocType has 'company' field
|
||||
df = qb.DocType("DocField")
|
||||
if (
|
||||
not_allowed := qb.from_(df)
|
||||
.select(df.parent)
|
||||
.where((df.fieldname == "company") & (df.parent == doc.doctype))
|
||||
.run()
|
||||
):
|
||||
if qb.from_(df).select(df.parent).where((df.fieldname == "company") & (df.parent == doc.doctype)).run():
|
||||
is_deletion_doc_running(
|
||||
doc.company, _("Cannot make any transactions until the deletion job is completed")
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import typing
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
@@ -8,7 +8,7 @@ from frappe.model.document import Document
|
||||
|
||||
|
||||
class ItemVariantSettings(Document):
|
||||
invalid_fields_for_copy_fields_in_variants = ["barcodes"]
|
||||
invalid_fields_for_copy_fields_in_variants: typing.ClassVar[list] = ["barcodes"]
|
||||
|
||||
def set_default_fields(self):
|
||||
self.fields = []
|
||||
|
||||
@@ -182,12 +182,12 @@ class TestPackedItem(FrappeTestCase):
|
||||
def sort_function(p):
|
||||
return p.parent_item, p.item_code, p.qty
|
||||
|
||||
for sent, returned in zip(
|
||||
for sent_item, returned_item in zip(
|
||||
sorted(original, key=sort_function), sorted(returned, key=sort_function), strict=False
|
||||
):
|
||||
self.assertEqual(sent.item_code, returned.item_code)
|
||||
self.assertEqual(sent.parent_item, returned.parent_item)
|
||||
self.assertEqual(sent.qty, -1 * returned.qty)
|
||||
self.assertEqual(sent_item.item_code, returned_item.item_code)
|
||||
self.assertEqual(sent_item.parent_item, returned_item.parent_item)
|
||||
self.assertEqual(sent_item.qty, -1 * returned_item.qty)
|
||||
|
||||
def test_returning_full_bundles(self):
|
||||
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_return
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe.permissions import add_user_permission, remove_user_permission
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.utils import add_days, flt, nowdate, nowtime, today
|
||||
from frappe.utils import add_days, flt, nowtime, today
|
||||
|
||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||
from erpnext.stock.doctype.item.test_item import (
|
||||
@@ -518,10 +517,10 @@ class TestStockEntry(FrappeTestCase):
|
||||
self.assertTrue(sle)
|
||||
sle.sort(key=lambda x: x[1])
|
||||
|
||||
for i, sle in enumerate(sle):
|
||||
self.assertEqual(expected_sle[i][0], sle[0])
|
||||
self.assertEqual(expected_sle[i][1], sle[1])
|
||||
self.assertEqual(expected_sle[i][2], sle[2])
|
||||
for i, sle_value in enumerate(sle):
|
||||
self.assertEqual(expected_sle[i][0], sle_value[0])
|
||||
self.assertEqual(expected_sle[i][1], sle_value[1])
|
||||
self.assertEqual(expected_sle[i][2], sle_value[2])
|
||||
|
||||
def check_gl_entries(self, voucher_type, voucher_no, expected_gl_entries):
|
||||
expected_gl_entries.sort(key=lambda x: x[0])
|
||||
|
||||
@@ -900,14 +900,14 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin):
|
||||
receipt.submit()
|
||||
|
||||
expected_queues = []
|
||||
for idx, rate in enumerate(rates, start=1):
|
||||
for idx in range(1, len(rates) + 1):
|
||||
expected_queues.append({"stock_queue": [[10, 10 * i] for i in range(1, idx + 1)]})
|
||||
self.assertSLEs(receipt, expected_queues)
|
||||
|
||||
transfer = make_stock_entry(
|
||||
item_code=item.name, source=source, target=target, qty=10, do_not_save=True, rate=10
|
||||
)
|
||||
for rate in rates[1:]:
|
||||
for _ in rates[1:]:
|
||||
row = frappe.copy_doc(transfer.items[0], ignore_no_copy=False)
|
||||
transfer.append("items", row)
|
||||
|
||||
@@ -936,7 +936,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin):
|
||||
repack = make_stock_entry(
|
||||
item_code=rm.name, source=warehouse, qty=10, do_not_save=True, rate=10, purpose="Repack"
|
||||
)
|
||||
for rate in rates[1:]:
|
||||
for _ in rates[1:]:
|
||||
row = frappe.copy_doc(repack.items[0], ignore_no_copy=False)
|
||||
repack.append("items", row)
|
||||
|
||||
|
||||
@@ -550,9 +550,7 @@ class StockReconciliation(StockController):
|
||||
|
||||
data.incoming_rate = (data.total_amount) / data.actual_qty
|
||||
|
||||
for key, value in merge_similar_entries.items():
|
||||
new_sl_entries.append(value)
|
||||
|
||||
new_sl_entries.extend(merge_similar_entries.values())
|
||||
return new_sl_entries
|
||||
|
||||
def get_gl_entries(self, warehouse_account=None):
|
||||
|
||||
@@ -188,7 +188,7 @@ def get_child_warehouses(warehouse):
|
||||
from frappe.utils.nestedset import get_descendants_of
|
||||
|
||||
children = get_descendants_of("Warehouse", warehouse, ignore_permissions=True, order_by="lft")
|
||||
return children + [warehouse] # append self for backward compatibility
|
||||
return [*children, warehouse] # append self for backward compatibility
|
||||
|
||||
|
||||
def get_warehouses_based_on_account(account, company=None):
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
import datetime
|
||||
from collections import OrderedDict
|
||||
from typing import Union
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
@@ -15,7 +14,7 @@ Filters = frappe._dict
|
||||
Row = frappe._dict
|
||||
Data = list[Row]
|
||||
Columns = list[dict[str, str]]
|
||||
DateTime = Union[datetime.date, datetime.datetime]
|
||||
DateTime = datetime.date | datetime.datetime
|
||||
FilteredEntries = list[dict[str, str | float | DateTime | None]]
|
||||
ItemGroupsDict = dict[tuple[int, int], dict[str, str | int]]
|
||||
SVDList = list[frappe._dict]
|
||||
|
||||
Reference in New Issue
Block a user