Frappe PR Bot 6826a1e976 chore(release): Bumped to Version 15.5.0
# [15.5.0](https://github.com/frappe/erpnext/compare/v15.4.0...v15.5.0) (2023-12-05)

### Bug Fixes

* `AttributeError` while saving Purchase Invoice (backport [#38482](https://github.com/frappe/erpnext/issues/38482)) ([#38490](https://github.com/frappe/erpnext/issues/38490)) ([f6c48e8](f6c48e8ecf))
* `OperationalError` while selecting Serial No in `Warranty Claim` (backport [#38394](https://github.com/frappe/erpnext/issues/38394)) ([#38414](https://github.com/frappe/erpnext/issues/38414)) ([80afeca](80afeca229))
* Add missing french translations ([#38368](https://github.com/frappe/erpnext/issues/38368)) ([b5c89ec](b5c89ec3b4))
* better overlap logic for job card (backport [#38432](https://github.com/frappe/erpnext/issues/38432)) ([#38522](https://github.com/frappe/erpnext/issues/38522)) ([2a9e843](2a9e843610))
* consider the `Valuation Method` while picking incorrect SLE (backport [#38592](https://github.com/frappe/erpnext/issues/38592)) ([#38595](https://github.com/frappe/erpnext/issues/38595)) ([9d45bbd](9d45bbd051))
* debit credit mismatch in multi-currecy asset purchase receipt ([#38342](https://github.com/frappe/erpnext/issues/38342)) ([b9f26ae](b9f26ae849))
* don't consider cancelled entries ([#38401](https://github.com/frappe/erpnext/issues/38401)) ([0a29dbe](0a29dbe09e))
* don't show non-stock items in Stock Analytics report (backport [#38543](https://github.com/frappe/erpnext/issues/38543)) ([#38545](https://github.com/frappe/erpnext/issues/38545)) ([282a5b2](282a5b27ad))
* don't update previous doc on rate change (backport [#38493](https://github.com/frappe/erpnext/issues/38493)) ([#38524](https://github.com/frappe/erpnext/issues/38524)) ([0aa96f7](0aa96f783d))
* exclude `invoice_doctypes` from party advance ([927538f](927538f776))
* exploded items in Subcontracting Receipt (backport [#38441](https://github.com/frappe/erpnext/issues/38441)) ([#38445](https://github.com/frappe/erpnext/issues/38445)) ([e066698](e06669847d))
* german translations for Lost Quotations (backport [#38435](https://github.com/frappe/erpnext/issues/38435)) ([#38516](https://github.com/frappe/erpnext/issues/38516)) ([33c59a2](33c59a2bb1))
* get dynamic link with parenttype contact ([cb9589b](cb9589b8ef))
* incorrect customer outstanding amount ([#38475](https://github.com/frappe/erpnext/issues/38475)) ([98fe89a](98fe89a24d))
* incorrect material request quantity in Production Plan (backport [#38566](https://github.com/frappe/erpnext/issues/38566)) ([#38579](https://github.com/frappe/erpnext/issues/38579)) ([145ed3a](145ed3a3b1))
* incorrect ordered qty for Subcontracting Order ([#38415](https://github.com/frappe/erpnext/issues/38415)) ([71fe2bc](71fe2bcc28))
* incorrect requested quantity for the subcontracting order ([abe3e41](abe3e41a17))
* incorrectly treating normal payment as advance ([#38437](https://github.com/frappe/erpnext/issues/38437)) ([246dd74](246dd74ba4))
* item group filter in sales person wise report ([602f6ca](602f6ca545))
* make create button translatable ([#38165](https://github.com/frappe/erpnext/issues/38165)) ([95f9cc9](95f9cc99b9))
* **regional:** use net figures for sales calc ([#38260](https://github.com/frappe/erpnext/issues/38260)) ([4a243ce](4a243ce5b7))
* remove hardcoded, implicit rounding loss allowance ([4baf796](4baf7960dd))
* scan for serial or batch in bundle (backport [#38534](https://github.com/frappe/erpnext/issues/38534)) ([#38552](https://github.com/frappe/erpnext/issues/38552)) ([88d2a8d](88d2a8d668))
* set cwip account before asset tests ([de7e1ab](de7e1ab237))
* show item name as title instead of item group in BOM (backport [#38478](https://github.com/frappe/erpnext/issues/38478)) ([#38481](https://github.com/frappe/erpnext/issues/38481)) ([8e57862](8e57862a1c))
* show party instead of party name where naming series not set ([f120dc5](f120dc56c2))
* sql error while filtering on finance book in GL ([3779943](3779943221))
* **test:** use correct account type for testing ([8b6eb35](8b6eb3599c))
* unset discount amount based on coupon code ([0e50e77](0e50e77d8e))
* use `docstatus` instead of `status` (backport [#38439](https://github.com/frappe/erpnext/issues/38439)) ([#38443](https://github.com/frappe/erpnext/issues/38443)) ([a50e872](a50e872820))
* use predefined onload property `load_after_mapping` ([#38209](https://github.com/frappe/erpnext/issues/38209)) ([4a558b7](4a558b7efb))
* **ux:** make valuation field read only when it can't be modified (backport [#38450](https://github.com/frappe/erpnext/issues/38450)) ([#38464](https://github.com/frappe/erpnext/issues/38464)) ([2d9ba88](2d9ba88870))
* validation error has not throw for the batch (backport [#38494](https://github.com/frappe/erpnext/issues/38494)) ([#38502](https://github.com/frappe/erpnext/issues/38502)) ([c797c53](c797c533ed))

### Features

* `Company` filter in `Stock Ledger Variance` report (backport [#38553](https://github.com/frappe/erpnext/issues/38553)) ([#38574](https://github.com/frappe/erpnext/issues/38574)) ([02d7dd8](02d7dd8b15))
* add customer group filter in sales register ([#38365](https://github.com/frappe/erpnext/issues/38365)) ([185b715](185b715d43))
* auto create PR on SCR submission (backport [#38290](https://github.com/frappe/erpnext/issues/38290)) ([#38428](https://github.com/frappe/erpnext/issues/38428)) ([7005d51](7005d51af3))
* enable automatic type annotations (backport [#38452](https://github.com/frappe/erpnext/issues/38452)) ([#38454](https://github.com/frappe/erpnext/issues/38454)) ([5e6a4d2](5e6a4d257e))
* shift depreciation for assets (backport [#38327](https://github.com/frappe/erpnext/issues/38327)) ([#38417](https://github.com/frappe/erpnext/issues/38417)) ([12ad1ec](12ad1ec71a))
2023-12-05 13:51:15 +00:00

154 lines
4.2 KiB
Python

import functools
import inspect
import frappe
__version__ = "15.5.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