Frappe PR Bot 54a6fbaeba chore(release): Bumped to Version 15.1.0
# [15.1.0](https://github.com/frappe/erpnext/compare/v15.0.0...v15.1.0) (2023-11-16)

### Bug Fixes

* `PermissionError` while creating DN from SO (backport [#37758](https://github.com/frappe/erpnext/issues/37758)) ([#37768](https://github.com/frappe/erpnext/issues/37768)) ([e742310](e7423109b6))
* `TypeError` in PR for non-stock item (backport [#37819](https://github.com/frappe/erpnext/issues/37819)) ([#37842](https://github.com/frappe/erpnext/issues/37842)) ([847dd9e](847dd9e671))
* add translation wrapper (backport [#37911](https://github.com/frappe/erpnext/issues/37911)) ([#37947](https://github.com/frappe/erpnext/issues/37947)) ([915ca47](915ca47515))
* asset depreciation ledger (backport [#37991](https://github.com/frappe/erpnext/issues/37991)) ([#37993](https://github.com/frappe/erpnext/issues/37993)) ([b3562bd](b3562bdb87))
* avoid name clash in delivery stop (backport [#37306](https://github.com/frappe/erpnext/issues/37306)) ([#37702](https://github.com/frappe/erpnext/issues/37702)) ([bfd240a](bfd240a19d))
* close `Credit Limit Crossed` dialog (backport [#38052](https://github.com/frappe/erpnext/issues/38052)) ([#38059](https://github.com/frappe/erpnext/issues/38059)) ([cff56d4](cff56d4e50))
* COA Importer app related issues ([#37238](https://github.com/frappe/erpnext/issues/37238)) ([d5bf7a0](d5bf7a039d))
* consider reserved stock while cancelling a stock transaction (backport [#37754](https://github.com/frappe/erpnext/issues/37754)) ([#37906](https://github.com/frappe/erpnext/issues/37906)) ([e0b0b6b](e0b0b6bb7d))
* credit note receive payment entry ([9781f9b](9781f9b7b1))
* **customer:** contact creation for companies ([#38055](https://github.com/frappe/erpnext/issues/38055)) ([fc09d75](fc09d757f0))
* **customer:** quick form and integration fixes ([#37386](https://github.com/frappe/erpnext/issues/37386)) ([02e2258](02e225845e))
* **defaults:** apply discount and provisonal defaults from item group and brand if available (backport [#37466](https://github.com/frappe/erpnext/issues/37466)) ([#37704](https://github.com/frappe/erpnext/issues/37704)) ([f382b1c](f382b1cf61))
* deprecate unused create_contact ([6f2b34e](6f2b34e7d5))
* don't reset rate if greater than zero in standalone debit note (backport [#37935](https://github.com/frappe/erpnext/issues/37935)) ([#37941](https://github.com/frappe/erpnext/issues/37941)) ([e156564](e156564ea4))
* force delete removed report (backport [#37668](https://github.com/frappe/erpnext/issues/37668)) ([#37670](https://github.com/frappe/erpnext/issues/37670)) ([a871d95](a871d955d4))
* handle gle for standalone credit and debit notes ([6e463b1](6e463b1953))
* Identical items are added line by line instead of grouped together in POS ([#37986](https://github.com/frappe/erpnext/issues/37986)) ([011cf3d](011cf3d73e))
* ignore Stock Reservation for future dated PR (backport [#37979](https://github.com/frappe/erpnext/issues/37979)) ([#37990](https://github.com/frappe/erpnext/issues/37990)) ([d74f0ef](d74f0ef586))
* In-Transit Warehouse company filter (backport [#37796](https://github.com/frappe/erpnext/issues/37796)) ([#37798](https://github.com/frappe/erpnext/issues/37798)) ([254ec2c](254ec2cfd1))
* incorrect material request quantity in production plan (backport [#37785](https://github.com/frappe/erpnext/issues/37785)) ([#37790](https://github.com/frappe/erpnext/issues/37790)) ([8b3c4a9](8b3c4a948c))
* indentation issue in the Production Plan Summary report (backport [#38019](https://github.com/frappe/erpnext/issues/38019)) ([#38069](https://github.com/frappe/erpnext/issues/38069)) ([6d325a4](6d325a40a1))
* indexing on Delivery Note Item (backport [#37766](https://github.com/frappe/erpnext/issues/37766)) ([#37778](https://github.com/frappe/erpnext/issues/37778)) ([98a7c17](98a7c170a0))
* link between parent and child procedure (backport [#37903](https://github.com/frappe/erpnext/issues/37903)) ([#37944](https://github.com/frappe/erpnext/issues/37944)) ([a065f22](a065f22a4c))
* list index out of range (backport [#37890](https://github.com/frappe/erpnext/issues/37890)) ([#37920](https://github.com/frappe/erpnext/issues/37920)) ([e71ef10](e71ef10ca9))
* make `Material Request Item` required if `Material Request` is set in PO (backport [#37928](https://github.com/frappe/erpnext/issues/37928)) ([#37937](https://github.com/frappe/erpnext/issues/37937)) ([7ad0817](7ad08179f2))
* make adjustment entry using stock reconciliation (backport [#37995](https://github.com/frappe/erpnext/issues/37995)) ([#38009](https://github.com/frappe/erpnext/issues/38009)) ([b23fa1f](b23fa1f5dd))
* make changes that enable gantt view for job cards (backport [#37661](https://github.com/frappe/erpnext/issues/37661)) ([#37757](https://github.com/frappe/erpnext/issues/37757)) ([f132552](f132552968))
* make item field read-only in batch (backport [#38010](https://github.com/frappe/erpnext/issues/38010)) ([#38034](https://github.com/frappe/erpnext/issues/38034)) ([99b7cdb](99b7cdb5be))
* make project page translatable (backport [#37743](https://github.com/frappe/erpnext/issues/37743)) ([#37801](https://github.com/frappe/erpnext/issues/37801)) ([59e67cd](59e67cd384))
* Mark Status field in Payment Entry 'no_copy'. ([#38000](https://github.com/frappe/erpnext/issues/38000)) ([3c0f8b1](3c0f8b15a0))
* minor change added to test_case ([b1714ec](b1714ec21d))
* minor issue ([24be044](24be04427c))
* **minor:** set tax values for item variants (backport [#37674](https://github.com/frappe/erpnext/issues/37674)) ([#37739](https://github.com/frappe/erpnext/issues/37739)) ([5c46d74](5c46d7452e))
* new logic for handling revaluation journals ([fb71a6e](fb71a6e787))
* Not able to save subcontracting receipt ([#38085](https://github.com/frappe/erpnext/issues/38085)) ([a874997](a8749977e1))
* **packed_item:** ensure proper names for ref integrity (backport [#37597](https://github.com/frappe/erpnext/issues/37597)) ([#37794](https://github.com/frappe/erpnext/issues/37794)) ([9aa29f5](9aa29f55d9))
* permission error while creating Supplier Quotation from Portal (backport [#37864](https://github.com/frappe/erpnext/issues/37864)) ([#37871](https://github.com/frappe/erpnext/issues/37871)) ([be8399f](be8399f52e))
* **plaid:** Do not sync pending transactions ([2149de4](2149de44b1))
* POS change amount gl entry with no amount ([#37799](https://github.com/frappe/erpnext/issues/37799)) ([fd7a768](fd7a768535))
* Quality Inspection Parameter migration - DuplicateEntryError due to case sensitivity (backport [#37499](https://github.com/frappe/erpnext/issues/37499)) ([#37917](https://github.com/frappe/erpnext/issues/37917)) ([7d0f1f4](7d0f1f4235))
* remove from or target warehouse for non internal transfer entries (backport [#37612](https://github.com/frappe/erpnext/issues/37612)) ([#37627](https://github.com/frappe/erpnext/issues/37627)) ([3155790](31557902b8))
* remove validation for negative outstanding invoices ([8602a3e](8602a3eab1))
* remove voucher type and no for Item and Warehouse based reposting ([b96be67](b96be67a1f))
* sales order not assigned to territory orders (backport [#37905](https://github.com/frappe/erpnext/issues/37905)) ([#38025](https://github.com/frappe/erpnext/issues/38025)) ([40cc3a7](40cc3a7610))
* skip check for removed validation ([22e58e0](22e58e0ee0))
* sort by section code ([06bb1a3](06bb1a3208))
* standard submit perm in repost ledger for editable invoices (backport [#37826](https://github.com/frappe/erpnext/issues/37826)) ([#37855](https://github.com/frappe/erpnext/issues/37855)) ([71361f7](71361f7673))
* status for over delivery or billing ([95d6742](95d6742587))
* test for invoice returns ([a89af58](a89af589e8))
* type error on new payment entry ([5937135](59371358ae))
* typo in AR report ([fc3d303](fc3d303b82))
* typo in function name and msg (backport [#37722](https://github.com/frappe/erpnext/issues/37722)) ([#37741](https://github.com/frappe/erpnext/issues/37741)) ([4819fde](4819fde8c5))
* unsupported operand type(s) for serial and batch bundle in POS Invoice (backport [#37721](https://github.com/frappe/erpnext/issues/37721)) ([#37731](https://github.com/frappe/erpnext/issues/37731)) ([b03c65f](b03c65f21d))
* use get_all instead of get_list ([2a5b3bd](2a5b3bdfd9))
* validate so item with qtn ([71538cf](71538cfab1))
* valuation rate for the subcontracting receipt supplied items with Serial and Batch Bundle (backport [#38094](https://github.com/frappe/erpnext/issues/38094)) (backport [#38097](https://github.com/frappe/erpnext/issues/38097)) ([#38101](https://github.com/frappe/erpnext/issues/38101)) ([880cea5](880cea5b36))

### Features

* **accounts_receivable:** test_case added for multi-select customer group ([848efe8](848efe8047))
* add cols for supplier inv details ([e51e5b3](e51e5b36e2))
* allow return of components for SCO that don't have SCR created (backport [#37686](https://github.com/frappe/erpnext/issues/37686)) ([#37693](https://github.com/frappe/erpnext/issues/37693)) ([4044325](40443258cf))
* auto reserve stock for Sales Order on purchase (backport [#37603](https://github.com/frappe/erpnext/issues/37603)) ([#37648](https://github.com/frappe/erpnext/issues/37648)) ([da5bf50](da5bf501eb))
* **delivery:** link to delivery notes list view from delivery trip (backport [#37604](https://github.com/frappe/erpnext/issues/37604)) ([#37696](https://github.com/frappe/erpnext/issues/37696)) ([08ea62f](08ea62f4e4))
* multi-select customer group in AR Report ([fff294f](fff294fb37))
* proprietorship & partnership options in entity type ([6df125a](6df125a05f))
* reserved production plan sub assembly items (backport [#37884](https://github.com/frappe/erpnext/issues/37884)) ([#37927](https://github.com/frappe/erpnext/issues/37927)) ([df90fd7](df90fd7b35))
* settings page for repost ([c047fd7](c047fd7ac5))
* **Stock Balance:** add filters from route (backport [#37836](https://github.com/frappe/erpnext/issues/37836)) ([#37840](https://github.com/frappe/erpnext/issues/37840)) ([fad8228](fad8228a67))

### Performance Improvements

* Add index to supplier invoice field (backport [#37861](https://github.com/frappe/erpnext/issues/37861)) ([#37863](https://github.com/frappe/erpnext/issues/37863)) ([b1982a6](b1982a6961))
* index return against for purchase invoice (backport [#37881](https://github.com/frappe/erpnext/issues/37881)) ([#37883](https://github.com/frappe/erpnext/issues/37883)) ([febd20a](febd20acbc))
2023-11-16 06:51:17 +00:00

154 lines
4.2 KiB
Python

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