style: format code with black

This commit is contained in:
Ankush Menat
2022-03-28 18:52:46 +05:30
parent 21e00da3d6
commit 494bd9ef78
1395 changed files with 91704 additions and 62532 deletions

View File

@@ -17,23 +17,25 @@ def before_tests():
if not frappe.db.a_row_exists("Company"):
current_year = now_datetime().year
setup_complete({
"currency" :"USD",
"full_name" :"Test User",
"company_name" :"Wind Power LLC",
"timezone" :"America/New_York",
"company_abbr" :"WP",
"industry" :"Manufacturing",
"country" :"United States",
"fy_start_date" :f"{current_year}-01-01",
"fy_end_date" :f"{current_year}-12-31",
"language" :"english",
"company_tagline" :"Testing",
"email" :"test@erpnext.com",
"password" :"test",
"chart_of_accounts" : "Standard",
"domains" : ["Manufacturing"],
})
setup_complete(
{
"currency": "USD",
"full_name": "Test User",
"company_name": "Wind Power LLC",
"timezone": "America/New_York",
"company_abbr": "WP",
"industry": "Manufacturing",
"country": "United States",
"fy_start_date": f"{current_year}-01-01",
"fy_end_date": f"{current_year}-12-31",
"language": "english",
"company_tagline": "Testing",
"email": "test@erpnext.com",
"password": "test",
"chart_of_accounts": "Standard",
"domains": ["Manufacturing"],
}
)
_enable_all_domains()
frappe.db.sql("delete from `tabLeave Allocation`")
@@ -47,6 +49,7 @@ def before_tests():
frappe.db.commit()
@frappe.whitelist()
def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=None):
if not (from_currency and to_currency):
@@ -63,7 +66,7 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
filters = [
["date", "<=", get_datetime_str(transaction_date)],
["from_currency", "=", from_currency],
["to_currency", "=", to_currency]
["to_currency", "=", to_currency],
]
if args == "for_buying":
@@ -78,8 +81,8 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
# cksgb 19/09/2016: get last entry in Currency Exchange with from_currency and to_currency.
entries = frappe.get_all(
"Currency Exchange", fields=["exchange_rate"], filters=filters, order_by="date desc",
limit=1)
"Currency Exchange", fields=["exchange_rate"], filters=filters, order_by="date desc", limit=1
)
if entries:
return flt(entries[0].exchange_rate)
@@ -90,11 +93,12 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
if not value:
import requests
settings = frappe.get_cached_doc('Currency Exchange Settings')
settings = frappe.get_cached_doc("Currency Exchange Settings")
req_params = {
"transaction_date": transaction_date,
"from_currency": from_currency,
"to_currency": to_currency
"to_currency": to_currency,
}
params = {}
for row in settings.req_params:
@@ -109,18 +113,24 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
return flt(value)
except Exception:
frappe.log_error(title="Get Exchange Rate")
frappe.msgprint(_("Unable to find exchange rate for {0} to {1} for key date {2}. Please create a Currency Exchange record manually").format(from_currency, to_currency, transaction_date))
frappe.msgprint(
_(
"Unable to find exchange rate for {0} to {1} for key date {2}. Please create a Currency Exchange record manually"
).format(from_currency, to_currency, transaction_date)
)
return 0.0
def format_ces_api(data, param):
return data.format(
transaction_date=param.get("transaction_date"),
to_currency=param.get("to_currency"),
from_currency=param.get("from_currency")
from_currency=param.get("from_currency"),
)
def enable_all_roles_and_domains():
""" enable all roles and domain for testing """
"""enable all roles and domain for testing"""
_enable_all_domains()
_enable_all_roles_for_admin()
@@ -129,18 +139,19 @@ def _enable_all_domains():
domains = frappe.get_all("Domain", pluck="name")
if not domains:
return
frappe.get_single('Domain Settings').set_active_domains(domains)
frappe.get_single("Domain Settings").set_active_domains(domains)
def _enable_all_roles_for_admin():
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
all_roles = set(frappe.db.get_values("Role", pluck="name"))
admin_roles = set(frappe.db.get_values("Has Role",
{"parent": "Administrator"}, fieldname="role", pluck="role"))
admin_roles = set(
frappe.db.get_values("Has Role", {"parent": "Administrator"}, fieldname="role", pluck="role")
)
if all_roles.difference(admin_roles):
add_all_roles_to('Administrator')
add_all_roles_to("Administrator")
def set_defaults_for_tests():
@@ -150,7 +161,7 @@ def set_defaults_for_tests():
}
frappe.db.set_single_value("Selling Settings", defaults)
for key, value in defaults.items():
frappe.db.set_default(key, value)
frappe.db.set_default(key, value)
frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 0)
@@ -159,6 +170,7 @@ def insert_record(records):
make_records(records)
def welcome_email():
site_name = get_default_company() or "ERPNext"
title = _("Welcome to {0}").format(site_name)