mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
# [15.99.0](https://github.com/frappe/erpnext/compare/v15.98.1...v15.99.0) (2026-02-25) ### Bug Fixes * **`fiscal_year_company`:** made `company` field mandatory ([2fffc94](2fffc9448b)) * **`fiscal_year`:** `Fiscal Year` auto-generation and notification ([397f39e](397f39e271)) * `update_stock` behaviour on selling invoices ([82bcb62](82bcb62b21)) * Add handling for Sales Invoice Item quantity field ([41c7890](41c7890a6d)) * add purchase invoice as well ([2fc3e30](2fc3e30f9f)) * avoid duplicate taxes and charges rows in payment entry (backport [#52178](https://github.com/frappe/erpnext/issues/52178)) ([#52318](https://github.com/frappe/erpnext/issues/52318)) ([946c355](946c3554b1)) * better permissions on make payment request ([ce7101f](ce7101f555)) * bug with comparison regarding `None` values and empty string ([852c200](852c200ee0)) * check gl account of an associated bank account in bank transaction ([6b286ae](6b286ae03d)) * enfore permission on make_payment_request ([4602919](460291990a)) * get employee email with priority if preferred is not set ([943e2c0](943e2c00bc)) * ignore permissions instead of saving parent ([bce77b6](bce77b6117)) * inconsistent label name between parent and child ([1bf608f](1bf608f835)) * **manufacturing:** remove delete query of job card & batch and serial no ([#52840](https://github.com/frappe/erpnext/issues/52840)) ([e30b2f1](e30b2f1d04)) * **manufacturing:** set pick list purpose while creating it from work order ([33d48c5](33d48c5575)) * **manufacturing:** update status for work order before calculating planned qty ([b3bcfd5](b3bcfd5a64)) * permission issue for quotation item during update item ([5a3c027](5a3c027432)) * prevent precision errors in discount distribution with inclusive tax ([61ac180](61ac18069b)) * **Purchase Receipt:** copy project from first row when adding items ([fd48fb4](fd48fb49b9)) * remove supplier invoice date/posting date validation ([dcf4ac6](dcf4ac66bb)) * reservation based on field should be read only in SRE ([c3626d6](c3626d67ca)) * restore missing `has_permission` import ([0ba965a](0ba965aae6)) * **sales-order:** update quotation status while cancelling sales order ([#52822](https://github.com/frappe/erpnext/issues/52822)) ([2420122](2420122f0e)) * **sales-order:** update quotation status while cancelling sales order (backport [#52822](https://github.com/frappe/erpnext/issues/52822)) ([#52918](https://github.com/frappe/erpnext/issues/52918)) ([3ae5de7](3ae5de7b11)) * sensible insufficient stock message in pick list ([3bafa36](3bafa360b2)) * setup fails to set abbr to departments ([c432506](c432506912)) * skip empty dimension values in exchange gain loss ([09ba980](09ba9808de)) * typo ([3893900](38939005ca)) * unable to submit subcontracting order if created from material request ([0422117](0422117003)) * update items fetches wrong item code ([97a4a5f](97a4a5f1cc)) * **work_order:** update returned qty ([bb1a655](bb1a655efb)) ### Features * **Journal Entry Account:** add Bank Transaction as Reference Type (backport [#52760](https://github.com/frappe/erpnext/issues/52760)) ([#52815](https://github.com/frappe/erpnext/issues/52815)) ([7032197](7032197f97)) * retrieve employee basic contact information ([4b2ac62](4b2ac626c5)) * retrieve employee contact details ([caa03ef](caa03efbe1)) * update item button addition for quotation (backport [#50976](https://github.com/frappe/erpnext/issues/50976)) ([#52810](https://github.com/frappe/erpnext/issues/52810)) ([800e384](800e38453b)) * update item button addition for quotation (backport [#50976](https://github.com/frappe/erpnext/issues/50976)) ([#52810](https://github.com/frappe/erpnext/issues/52810)) ([e2a1a7a](e2a1a7a36d)) ### Reverts * Revert "feat: update item button addition for quotation (backport [#50976](https://github.com/frappe/erpnext/issues/50976)) ([#5](https://github.com/frappe/erpnext/issues/5)…" ([656b1bc](656b1bcede))
163 lines
4.4 KiB
Python
163 lines
4.4 KiB
Python
import functools
|
|
import inspect
|
|
|
|
import frappe
|
|
from frappe.utils.user import is_website_user
|
|
|
|
__version__ = "15.99.0"
|
|
|
|
|
|
def get_default_company(user=None):
|
|
"""Get default company for user"""
|
|
from frappe.defaults import get_user_default_as_list
|
|
|
|
if not user:
|
|
user = frappe.session.user
|
|
|
|
companies = get_user_default_as_list("company", user)
|
|
if companies:
|
|
default_company = companies[0]
|
|
else:
|
|
default_company = frappe.db.get_single_value("Global Defaults", "default_company")
|
|
|
|
return default_company
|
|
|
|
|
|
def get_default_currency():
|
|
"""Returns the currency of the default company"""
|
|
company = get_default_company()
|
|
if company:
|
|
return frappe.get_cached_value("Company", company, "default_currency")
|
|
|
|
|
|
def get_default_cost_center(company):
|
|
"""Returns the default cost center of the company"""
|
|
if not company:
|
|
return None
|
|
|
|
if not frappe.flags.company_cost_center:
|
|
frappe.flags.company_cost_center = {}
|
|
if company not in frappe.flags.company_cost_center:
|
|
frappe.flags.company_cost_center[company] = frappe.get_cached_value("Company", company, "cost_center")
|
|
return frappe.flags.company_cost_center[company]
|
|
|
|
|
|
def get_company_currency(company):
|
|
"""Returns the default company currency"""
|
|
if not frappe.flags.company_currency:
|
|
frappe.flags.company_currency = {}
|
|
if company not in frappe.flags.company_currency:
|
|
frappe.flags.company_currency[company] = frappe.db.get_value(
|
|
"Company", company, "default_currency", cache=True
|
|
)
|
|
return frappe.flags.company_currency[company]
|
|
|
|
|
|
def set_perpetual_inventory(enable=1, company=None):
|
|
if not company:
|
|
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
|
|
|
company = frappe.get_doc("Company", company)
|
|
company.enable_perpetual_inventory = enable
|
|
company.save()
|
|
|
|
|
|
def encode_company_abbr(name, company=None, abbr=None):
|
|
"""Returns name encoded with company abbreviation"""
|
|
company_abbr = abbr or frappe.get_cached_value("Company", company, "abbr")
|
|
parts = name.rsplit(" - ", 1)
|
|
|
|
if parts[-1].lower() != company_abbr.lower():
|
|
parts.append(company_abbr)
|
|
|
|
return " - ".join(parts)
|
|
|
|
|
|
def is_perpetual_inventory_enabled(company):
|
|
if not company:
|
|
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
|
|
|
if not hasattr(frappe.local, "enable_perpetual_inventory"):
|
|
frappe.local.enable_perpetual_inventory = {}
|
|
|
|
if company not in frappe.local.enable_perpetual_inventory:
|
|
frappe.local.enable_perpetual_inventory[company] = (
|
|
frappe.get_cached_value("Company", company, "enable_perpetual_inventory") or 0
|
|
)
|
|
|
|
return frappe.local.enable_perpetual_inventory[company]
|
|
|
|
|
|
def get_default_finance_book(company=None):
|
|
if not company:
|
|
company = get_default_company()
|
|
|
|
if not hasattr(frappe.local, "default_finance_book"):
|
|
frappe.local.default_finance_book = {}
|
|
|
|
if company not in frappe.local.default_finance_book:
|
|
frappe.local.default_finance_book[company] = frappe.get_cached_value(
|
|
"Company", company, "default_finance_book"
|
|
)
|
|
|
|
return frappe.local.default_finance_book[company]
|
|
|
|
|
|
def get_party_account_type(party_type):
|
|
if not hasattr(frappe.local, "party_account_types"):
|
|
frappe.local.party_account_types = {}
|
|
|
|
if party_type not in frappe.local.party_account_types:
|
|
frappe.local.party_account_types[party_type] = (
|
|
frappe.db.get_value("Party Type", party_type, "account_type") or ""
|
|
)
|
|
|
|
return frappe.local.party_account_types[party_type]
|
|
|
|
|
|
def get_region(company=None):
|
|
"""Return the default country based on flag, company or global settings
|
|
|
|
You can also set global company flag in `frappe.flags.company`
|
|
"""
|
|
|
|
if not company:
|
|
company = frappe.local.flags.company
|
|
|
|
if company:
|
|
return frappe.get_cached_value("Company", company, "country")
|
|
|
|
return frappe.flags.country or frappe.get_system_settings("country")
|
|
|
|
|
|
def allow_regional(fn):
|
|
"""Decorator to make a function regionally overridable
|
|
|
|
Example:
|
|
@erpnext.allow_regional
|
|
def myfunction():
|
|
pass"""
|
|
|
|
@functools.wraps(fn)
|
|
def caller(*args, **kwargs):
|
|
overrides = frappe.get_hooks("regional_overrides", {}).get(get_region())
|
|
function_path = f"{inspect.getmodule(fn).__name__}.{fn.__name__}"
|
|
|
|
if not overrides or function_path not in overrides:
|
|
return fn(*args, **kwargs)
|
|
|
|
# Priority given to last installed app
|
|
return frappe.get_attr(overrides[function_path][-1])(*args, **kwargs)
|
|
|
|
return caller
|
|
|
|
|
|
def check_app_permission():
|
|
if frappe.session.user == "Administrator":
|
|
return True
|
|
|
|
if is_website_user():
|
|
return False
|
|
|
|
return True
|