diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 75f552fe195..13defdecd1f 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -7,6 +7,7 @@ import json import frappe from frappe import _, msgprint from frappe.desk.notifications import clear_doctype_notifications +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.utils import cint, cstr, flt, get_link_to_form @@ -674,7 +675,7 @@ def item_last_purchase_rate(name, conversion_rate, item_code, conversion_factor= @frappe.whitelist() -def close_or_unclose_purchase_orders(names, status): +def close_or_unclose_purchase_orders(names: str, status: str): if not frappe.has_permission("Purchase Order", "write"): frappe.throw(_("Not permitted"), frappe.PermissionError) @@ -702,7 +703,9 @@ def set_missing_values(source, target): @frappe.whitelist() -def make_purchase_receipt(source_name, target_doc=None, args=None): +def make_purchase_receipt( + source_name: str, target_doc: str | Document | None = None, args: str | dict | None = None +): if args is None: args = {} if isinstance(args, str): @@ -766,12 +769,14 @@ def make_purchase_receipt(source_name, target_doc=None, args=None): @frappe.whitelist() -def make_purchase_invoice(source_name, target_doc=None, args=None): +def make_purchase_invoice( + source_name: str, target_doc: str | Document | None = None, args: str | None = None +): return get_mapped_purchase_invoice(source_name, target_doc, args=args) @frappe.whitelist() -def make_purchase_invoice_from_portal(purchase_order_name): +def make_purchase_invoice_from_portal(purchase_order_name: str): doc = get_mapped_purchase_invoice(purchase_order_name, ignore_permissions=True) if frappe.session.user not in frappe.get_all("Portal User", {"parent": doc.supplier}, pluck="user"): frappe.throw(_("Not Permitted"), frappe.PermissionError) @@ -884,21 +889,23 @@ def get_list_context(context=None): @frappe.whitelist() -def update_status(status, name): +def update_status(status: str, name: str): po = frappe.get_lazy_doc("Purchase Order", name) po.update_status(status) po.update_delivered_qty_in_sales_order() @frappe.whitelist() -def make_inter_company_sales_order(source_name, target_doc=None): +def make_inter_company_sales_order(source_name: str, target_doc: str | Document | None = None): from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_transaction return make_inter_company_transaction("Purchase Order", source_name, target_doc) @frappe.whitelist() -def make_subcontracting_order(source_name, target_doc=None, save=False, submit=False, notify=False): +def make_subcontracting_order( + source_name: str, target_doc=None, save=False, submit: bool = False, notify: bool = False +): if not is_po_fully_subcontracted(source_name): target_doc = get_mapped_subcontracting_order(source_name, target_doc) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 95727472112..75a5275573d 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -8,6 +8,7 @@ import frappe from frappe import _ from frappe.core.doctype.communication.email import make from frappe.desk.form.load import get_attachments +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.query_builder import Order from frappe.utils import get_url @@ -164,7 +165,7 @@ class RequestforQuotation(BuyingController): self.db_set("status", "Cancelled") @frappe.whitelist() - def get_supplier_email_preview(self, supplier): + def get_supplier_email_preview(self, supplier: str): """Returns formatted email preview as string.""" rfq_suppliers = list(filter(lambda row: row.supplier == supplier, self.suppliers)) rfq_supplier = rfq_suppliers[0] @@ -385,7 +386,7 @@ class RequestforQuotation(BuyingController): @frappe.whitelist() -def send_supplier_emails(rfq_name): +def send_supplier_emails(rfq_name: str): check_portal_enabled("Request for Quotation") rfq = frappe.get_doc("Request for Quotation", rfq_name) if rfq.docstatus == 1: @@ -418,7 +419,9 @@ def get_list_context(context=None): @frappe.whitelist() -def make_supplier_quotation_from_rfq(source_name, target_doc=None, for_supplier=None): +def make_supplier_quotation_from_rfq( + source_name: str, target_doc: str | Document | None = None, for_supplier: str | None = None +): def postprocess(source, target_doc): if for_supplier: target_doc.supplier = for_supplier @@ -458,7 +461,7 @@ def make_supplier_quotation_from_rfq(source_name, target_doc=None, for_supplier= # This method is used to make supplier quotation from supplier's portal. @frappe.whitelist() -def create_supplier_quotation(doc): +def create_supplier_quotation(doc: str | dict): if isinstance(doc, str): doc = json.loads(doc) @@ -548,7 +551,9 @@ def get_pdf( @frappe.whitelist() -def get_item_from_material_requests_based_on_supplier(source_name, target_doc=None): +def get_item_from_material_requests_based_on_supplier( + source_name: str, target_doc: str | Document | None = None +): mr_items_list = frappe.db.sql( """ SELECT @@ -612,7 +617,9 @@ def get_supplier_tag(): @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def get_rfq_containing_supplier(doctype, txt, searchfield, start, page_len, filters): +def get_rfq_containing_supplier( + doctype: str | None, txt: str, searchfield: str | None, start: int, page_len: int, filters: dict +): rfq = frappe.qb.DocType("Request for Quotation") rfq_supplier = frappe.qb.DocType("Request for Quotation Supplier") diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 6a7332411d0..b9adc94dd16 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -224,7 +224,9 @@ class Supplier(TransactionBase): @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def get_supplier_primary(doctype, txt, searchfield, start, page_len, filters): +def get_supplier_primary( + doctype: str | None, txt: str, searchfield: str | None, start: int, page_len: int, filters: dict +): supplier = filters.get("supplier") type = filters.get("type") type_doctype = frappe.qb.DocType(type) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index c3ba8c40cf3..4f94a89870b 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -6,6 +6,7 @@ import json import frappe from frappe import _ +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.utils import flt, getdate, nowdate @@ -240,7 +241,9 @@ def get_list_context(context=None): @frappe.whitelist() -def make_purchase_order(source_name, target_doc=None, args=None): +def make_purchase_order( + source_name: str, target_doc: str | Document | None = None, args: str | dict | None = None +): if args is None: args = {} if isinstance(args, str): @@ -294,7 +297,7 @@ def make_purchase_order(source_name, target_doc=None, args=None): @frappe.whitelist() -def make_purchase_invoice(source_name, target_doc=None): +def make_purchase_invoice(source_name: str, target_doc: str | Document | None = None): doc = get_mapped_doc( "Supplier Quotation", source_name, @@ -315,7 +318,7 @@ def make_purchase_invoice(source_name, target_doc=None): @frappe.whitelist() -def make_quotation(source_name, target_doc=None): +def make_quotation(source_name: str, target_doc: str | Document | None = None): doclist = get_mapped_doc( "Supplier Quotation", source_name, diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py index a1142715e2c..7aaaceaed08 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py @@ -146,7 +146,7 @@ class SupplierScorecard(Document): @frappe.whitelist() -def get_timeline_data(doctype, name): +def get_timeline_data(doctype: str, name: str): # Get a list of all the associated scorecards scs = frappe.get_doc(doctype, name) out = {} @@ -198,7 +198,7 @@ def refresh_scorecards(): @frappe.whitelist() -def make_all_scorecards(docname): +def make_all_scorecards(docname: str): sc = frappe.get_doc("Supplier Scorecard", docname) supplier = frappe.get_doc("Supplier", sc.supplier) diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py index 690838a28ac..7f1be82c343 100644 --- a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py +++ b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py @@ -32,7 +32,7 @@ class SupplierScorecardStanding(Document): @frappe.whitelist() -def get_scoring_standing(standing_name): +def get_scoring_standing(standing_name: str): standing = frappe.get_doc("Supplier Scorecard Standing", standing_name) return standing diff --git a/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py b/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py index 09bfc12a351..273d5c90982 100644 --- a/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py +++ b/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py @@ -295,7 +295,7 @@ def get_message(): @frappe.whitelist() -def set_default_supplier(item_code, supplier, company): +def set_default_supplier(item_code: str, supplier: str, company: str): frappe.db.set_value( "Item Default", {"parent": item_code, "company": company}, diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py index 54f00417a89..c9d05a53099 100644 --- a/erpnext/buying/utils.py +++ b/erpnext/buying/utils.py @@ -117,7 +117,7 @@ def check_on_hold_or_closed_status(doctype, docname) -> None: @frappe.whitelist() -def get_linked_material_requests(items): +def get_linked_material_requests(items: str): items = json.loads(items) mr_list = [] for item in items: