Merge pull request #53032 from diptanilsaha/setup_ta

This commit is contained in:
diptanilsaha
2026-03-07 02:29:29 +05:30
committed by GitHub
13 changed files with 58 additions and 27 deletions

View File

@@ -656,7 +656,11 @@ def set_gl_entries_by_account(
query = query.where(Criterion.all(additional_conditions))
gl_entries = query.run(as_dict=True)
if filters and filters.get("presentation_currency") != d.default_currency:
if (
filters
and filters.get("presentation_currency")
and filters.get("presentation_currency") != d.default_currency
):
currency_info["company"] = d.name
currency_info["company_currency"] = d.default_currency
convert_to_presentation_currency(gl_entries, currency_info)

View File

@@ -49,6 +49,7 @@ class TestReactivity(AccountsTestMixin, IntegrationTestCase):
"debit_to": self.debit_to,
"posting_date": today(),
"cost_center": self.cost_center,
"currency": "INR",
"conversion_rate": 1,
"selling_price_list": self.price_list,
}

View File

@@ -1612,12 +1612,14 @@ def make_purchase_order(
def set_missing_values(source, target):
target.supplier = supplier
target.currency = frappe.db.get_value(
"Supplier", filters={"name": supplier}, fieldname=["default_currency"]
)
company_currency = frappe.db.get_value(
"Company", filters={"name": target.company}, fieldname=["default_currency"]
)
supplier_currency = frappe.db.get_value(
"Supplier", filters={"name": supplier}, fieldname=["default_currency"]
)
target.currency = supplier_currency if supplier_currency else company_currency
target.conversion_rate = get_exchange_rate(target.currency, company_currency, args="for_buying")

View File

@@ -3,6 +3,7 @@
import json
from typing import Literal
import frappe
import frappe.defaults
@@ -938,7 +939,7 @@ def cache_companies_monthly_sales_history():
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False):
def get_children(doctype: str, parent: str | None = None, company: str | None = None, is_root: bool = False):
if parent is None or parent == "All Companies":
parent = ""
@@ -1045,10 +1046,11 @@ def get_timeline_data(doctype, name):
@frappe.whitelist()
def get_default_company_address(name, sort_key="is_primary_address", existing_address=None):
if sort_key not in ["is_shipping_address", "is_primary_address"]:
return None
def get_default_company_address(
name: str,
sort_key: Literal["is_shipping_address", "is_primary_address"] = "is_primary_address",
existing_address: str | None = None,
):
out = frappe.db.sql(
""" SELECT
addr.name, addr.{}
@@ -1072,7 +1074,9 @@ def get_default_company_address(name, sort_key="is_primary_address", existing_ad
@frappe.whitelist()
def get_billing_shipping_address(name, billing_address=None, shipping_address=None):
def get_billing_shipping_address(
name: str, billing_address: str | None = None, shipping_address: str | None = None
):
primary_address = get_default_company_address(name, "is_primary_address", billing_address)
shipping_address = get_default_company_address(name, "is_shipping_address", shipping_address)
@@ -1080,7 +1084,7 @@ def get_billing_shipping_address(name, billing_address=None, shipping_address=No
@frappe.whitelist()
def create_transaction_deletion_request(company):
def create_transaction_deletion_request(company: str):
frappe.only_for("System Manager")
from erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record import (

View File

@@ -70,7 +70,13 @@ def get_abbreviated_name(name, company):
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, include_disabled=False):
def get_children(
doctype: str,
parent: str | None = None,
company: str | None = None,
is_root: bool = False,
include_disabled: str | dict | None = None,
):
if isinstance(include_disabled, str):
include_disabled = json.loads(include_disabled)
fields = ["name as value", "is_group as expandable"]

View File

@@ -900,7 +900,7 @@ def send():
@frappe.whitelist()
def get_digest_msg(name):
def get_digest_msg(name: str):
return frappe.get_doc("Email Digest", name).get_msg_html()

View File

@@ -304,7 +304,7 @@ def is_holiday(employee, date=None, raise_exception=True, only_non_weekly=False,
@frappe.whitelist()
def deactivate_sales_person(status=None, employee=None):
def deactivate_sales_person(status: str | None = None, employee: str | None = None):
if status == "Left":
sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
if sales_person:
@@ -312,7 +312,7 @@ def deactivate_sales_person(status=None, employee=None):
@frappe.whitelist()
def create_user(employee, user=None, email=None):
def create_user(employee: str, email: str | None = None):
emp = frappe.get_doc("Employee", employee)
employee_name = emp.employee_name.split(" ")
@@ -384,7 +384,13 @@ def get_employee_emails(employee_list):
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
def get_children(
doctype: str,
parent: str | None = None,
company: str | None = None,
is_root: bool = False,
is_tree: bool = False,
):
filters = [["status", "=", "Active"]]
if company and company != "All Companies":
filters.append(["company", "=", company])

View File

@@ -8,7 +8,7 @@ from datetime import date
import frappe
from frappe import _, throw
from frappe.model.document import Document
from frappe.utils import formatdate, getdate, today
from frappe.utils import DateTimeLikeObject, formatdate, getdate, today
class OverlapError(frappe.ValidationError):
@@ -168,7 +168,7 @@ class HolidayList(Document):
@frappe.whitelist()
def get_events(start, end, filters=None):
def get_events(start: DateTimeLikeObject, end: DateTimeLikeObject, filters: str | dict | None = None):
"""Returns events for Gantt / Calendar view rendering.
:param start: Start date-time.

View File

@@ -24,7 +24,7 @@ class PartyType(Document):
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def get_party_type(doctype, txt, searchfield, start, page_len, filters):
def get_party_type(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict):
cond = ""
account_type = None

View File

@@ -35,7 +35,7 @@ class TermsandConditions(Document):
@frappe.whitelist()
def get_terms_and_conditions(template_name, doc):
def get_terms_and_conditions(template_name: str, doc: str | dict):
if isinstance(doc, str):
doc = json.loads(doc)

View File

@@ -75,7 +75,7 @@ def get_protected_doctypes():
@frappe.whitelist()
def get_company_link_fields(doctype_name):
def get_company_link_fields(doctype_name: str):
"""Get all Company Link field names for a DocType (whitelisted for frontend autocomplete)
Args:
@@ -428,7 +428,9 @@ class TransactionDeletionRecord(Document):
return {"count": len(self.doctypes_to_delete)}
@frappe.whitelist()
def populate_doctype_details(self, doctype_name, company=None, company_field=None):
def populate_doctype_details(
self, doctype_name: str, company: str | None = None, company_field: str | None = None
):
"""Get child DocTypes and document count for specified DocType
Args:
@@ -1035,7 +1037,7 @@ def get_doctypes_to_be_ignored():
@frappe.whitelist()
def export_to_delete_template(name):
def export_to_delete_template(name: str):
"""Export To Delete list as CSV via URL access"""
frappe.only_for("System Manager")
doc = frappe.get_doc("Transaction Deletion Record", name)
@@ -1044,7 +1046,7 @@ def export_to_delete_template(name):
@frappe.whitelist()
def process_import_template(transaction_deletion_record_name, file_url):
def process_import_template(transaction_deletion_record_name: str, file_url: str):
"""Import CSV template and populate To Delete list"""
import os

View File

@@ -4,7 +4,7 @@
import frappe
from frappe import _
from frappe.utils import add_days, flt, get_datetime_str, nowdate
from frappe.utils.data import now_datetime
from frappe.utils.data import DateTimeLikeObject, now_datetime
from frappe.utils.nestedset import get_root_of
from erpnext import get_default_company
@@ -92,7 +92,12 @@ def get_pegged_rate(pegged_map, from_currency, to_currency, transaction_date=Non
@frappe.whitelist()
def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=None):
def get_exchange_rate(
from_currency: str,
to_currency: str,
transaction_date: DateTimeLikeObject | None = None,
args: str | None = None,
):
if not (from_currency and to_currency):
# manqala 19/09/2016: Should this be an empty return or should it throw and exception?
return

View File

@@ -11,8 +11,9 @@ class TestGetItemDetail(IntegrationTestCase):
args = frappe._dict(
{
"item_code": "_Test Item",
"company": "_Test Company",
"company": "_Test Company 1",
"customer": "_Test Customer",
"currency": "USD",
"conversion_rate": 1.0,
"price_list_currency": "USD",
"plc_conversion_rate": 1.0,