mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-19 02:04:50 +00:00
# [14.26.0](https://github.com/frappe/erpnext/compare/v14.25.1...v14.26.0) (2023-05-31) ### Bug Fixes * account group totals calculation to consider include_in_gross ([8dcb930](8dcb9302b4)) * add total col for gross and net profit ([cb9b4fb](cb9b4fbb91)) * available qty not fetching for raw material in PP ([746a734](746a734257)) * balance quantity ([56ba7d6](56ba7d6a8a)) * Billing Address display in buying transactions ([#35451](https://github.com/frappe/erpnext/issues/35451)) ([33e8d05](33e8d05718)) * don't map items twice ([6f0c7cf](6f0c7cf9a4)) * Error while validating budget ([#35487](https://github.com/frappe/erpnext/issues/35487)) ([5fd00e7](5fd00e7113)) * **Gross Profit:** 'company' column is ambiguous in filter ([a59c205](a59c205d2e)) * incorrect `POS Reserved Qty` in `Stock Projected Qty` Report ([71e4f34](71e4f34b86)) * incorrect available quantity in BIN ([5a9452f](5a9452f4a3)) * incorrect transferred qty in the job card ([#35478](https://github.com/frappe/erpnext/issues/35478)) ([86801c2](86801c29cb)) * make DN item reference mandatory for Packing Slip Item ([b4e481a](b4e481a390)) * map `Packed Items` while creating `Packing Slip` ([984e32c](984e32c34a)) * monthly WDV depr schedule for existing assets [v14] ([#35458](https://github.com/frappe/erpnext/issues/35458)) ([37d437a](37d437a33c)) * Negative value in Reserved Qty for Production Plan ([6fe42c9](6fe42c937c)) * Packing Slip Item Qty ([5345ebe](5345ebe242)) * **patch:** add patch to set `packed_qty` in draft DN ([b3da2f7](b3da2f7c26)) * rate not fetching properly for inter transfer purchase order ([7b75f45](7b75f454d3)) * remove duplicate items validation ([c7628c9](c7628c98c5)) * retention stock entry: grab conversion factor from source ([bd75584](bd75584c27)) * Show future payments in accounts receivable summary ([#35416](https://github.com/frappe/erpnext/issues/35416)) ([11440cc](11440cca4c)) * Stock Analytics and Warehouse wise Item Balance Age and Value issue ([2058993](205899348a)) * stock onboarding (backport [#35453](https://github.com/frappe/erpnext/issues/35453)) ([#35480](https://github.com/frappe/erpnext/issues/35480)) ([d231b19](d231b19b9f)) * tab-uniformity (backport [#35400](https://github.com/frappe/erpnext/issues/35400)) ([#35402](https://github.com/frappe/erpnext/issues/35402)) ([989052c](989052c075)) * travis ([fe1e2fe](fe1e2fec7a)) * update `Packed Qty` in DN on submit and cancel of `Packing Slip` ([0bed062](0bed06284e)) * **ux:** don't show `Create > Packing Slip` button if items are already packed ([9854c84](9854c84ad8)) * **ux:** get items on selecting DN in Packing Slip ([b96aa75](b96aa75ded)) * **ux:** remove `Get Items` button from `Packing Slip` ([4017342](4017342c15)) * validate Packing Slip Item Qty with DN Items ([cc7e267](cc7e267c35)) ### Features * add field `Packed Qty` in `Delivery Note Item` and `Packed Item` ([509b684](509b68404c)) * add field `pi_detail` in `Packing Slip` ([2b75474](2b75474649))
154 lines
4.2 KiB
Python
154 lines
4.2 KiB
Python
import functools
|
|
import inspect
|
|
|
|
import frappe
|
|
|
|
__version__ = "14.26.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(user, "company")
|
|
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 not company 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 not company 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 not company 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 not company 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 not party_type 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
|