mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 18:45:20 +00:00
Merge branch 'develop' into holiday-list-assignment
This commit is contained in:
@@ -117,6 +117,7 @@
|
||||
"enable_item_wise_inventory_account",
|
||||
"enable_provisional_accounting_for_non_stock_items",
|
||||
"default_inventory_account",
|
||||
"valuation_method",
|
||||
"column_break_32",
|
||||
"stock_adjustment_account",
|
||||
"stock_received_but_not_billed",
|
||||
@@ -124,6 +125,10 @@
|
||||
"default_in_transit_warehouse",
|
||||
"manufacturing_section",
|
||||
"default_operating_cost_account",
|
||||
"column_break_9prc",
|
||||
"default_wip_warehouse",
|
||||
"default_fg_warehouse",
|
||||
"default_scrap_warehouse",
|
||||
"dashboard_tab"
|
||||
],
|
||||
"fields": [
|
||||
@@ -885,6 +890,39 @@
|
||||
"fieldname": "enable_item_wise_inventory_account",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Item-wise Inventory Account"
|
||||
},
|
||||
{
|
||||
"default": "FIFO",
|
||||
"fieldname": "valuation_method",
|
||||
"fieldtype": "Select",
|
||||
"label": "Default Stock Valuation Method",
|
||||
"options": "FIFO\nMoving Average\nLIFO",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "default_wip_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": " Default Work In Progress Warehouse ",
|
||||
"link_filters": "[[\"Warehouse\",\"disabled\",\"=\",0]]",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_fg_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Finished Goods Warehouse",
|
||||
"link_filters": "[[\"Warehouse\",\"disabled\",\"=\",0]]",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_scrap_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Scrap Warehouse",
|
||||
"link_filters": "[[\"Warehouse\",\"disabled\",\"=\",0]]",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9prc",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-building",
|
||||
@@ -892,7 +930,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2025-10-23 13:15:52.411984",
|
||||
"modified": "2025-11-16 16:50:27.624096",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -59,6 +59,7 @@ class Company(NestedSet):
|
||||
default_deferred_revenue_account: DF.Link | None
|
||||
default_discount_account: DF.Link | None
|
||||
default_expense_account: DF.Link | None
|
||||
default_fg_warehouse: DF.Link | None
|
||||
default_finance_book: DF.Link | None
|
||||
default_holiday_list: DF.Link | None
|
||||
default_in_transit_warehouse: DF.Link | None
|
||||
@@ -69,8 +70,10 @@ class Company(NestedSet):
|
||||
default_payable_account: DF.Link | None
|
||||
default_provisional_account: DF.Link | None
|
||||
default_receivable_account: DF.Link | None
|
||||
default_scrap_warehouse: DF.Link | None
|
||||
default_selling_terms: DF.Link | None
|
||||
default_warehouse_for_sales_return: DF.Link | None
|
||||
default_wip_warehouse: DF.Link | None
|
||||
depreciation_cost_center: DF.Link | None
|
||||
depreciation_expense_account: DF.Link | None
|
||||
disposal_account: DF.Link | None
|
||||
@@ -113,6 +116,7 @@ class Company(NestedSet):
|
||||
transactions_annual_history: DF.Code | None
|
||||
unrealized_exchange_gain_loss_account: DF.Link | None
|
||||
unrealized_profit_loss_account: DF.Link | None
|
||||
valuation_method: DF.Literal["FIFO", "Moving Average", "LIFO"]
|
||||
website: DF.Data | None
|
||||
write_off_account: DF.Link | None
|
||||
# end: auto-generated types
|
||||
@@ -163,6 +167,32 @@ class Company(NestedSet):
|
||||
self.validate_parent_company()
|
||||
self.set_reporting_currency()
|
||||
self.validate_inventory_account_settings()
|
||||
self.cant_change_valuation_method()
|
||||
|
||||
def cant_change_valuation_method(self):
|
||||
doc_before_save = self.get_doc_before_save()
|
||||
if not doc_before_save:
|
||||
return
|
||||
|
||||
previous_valuation_method = doc_before_save.get("valuation_method")
|
||||
|
||||
if previous_valuation_method and previous_valuation_method != self.valuation_method:
|
||||
# check if there are any stock ledger entries against items
|
||||
# which does not have it's own valuation method
|
||||
sle = frappe.db.sql(
|
||||
"""select name from `tabStock Ledger Entry` sle
|
||||
where exists(select name from tabItem
|
||||
where name=sle.item_code and (valuation_method is null or valuation_method='')) and sle.company=%s limit 1
|
||||
""",
|
||||
self.name,
|
||||
)
|
||||
|
||||
if sle:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Can't change the valuation method, as there are transactions against some items which do not have its own valuation method"
|
||||
)
|
||||
)
|
||||
|
||||
def validate_inventory_account_settings(self):
|
||||
doc_before_save = self.get_doc_before_save()
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
import os
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||
from frappe.utils import cint
|
||||
|
||||
from erpnext.setup.doctype.incoterm.incoterm import create_incoterms
|
||||
from erpnext.setup.utils import identity as _
|
||||
|
||||
from .default_success_action import get_default_success_action
|
||||
|
||||
@@ -184,33 +183,27 @@ def add_company_to_session_defaults():
|
||||
|
||||
def add_standard_navbar_items():
|
||||
navbar_settings = frappe.get_single("Navbar Settings")
|
||||
|
||||
# Translatable strings for below navbar items
|
||||
__ = _("Documentation")
|
||||
__ = _("User Forum")
|
||||
__ = _("Report an Issue")
|
||||
|
||||
erpnext_navbar_items = [
|
||||
{
|
||||
"item_label": "Documentation",
|
||||
"item_label": _("Documentation"),
|
||||
"item_type": "Route",
|
||||
"route": "https://docs.erpnext.com/",
|
||||
"is_standard": 1,
|
||||
},
|
||||
{
|
||||
"item_label": "User Forum",
|
||||
"item_label": _("User Forum"),
|
||||
"item_type": "Route",
|
||||
"route": "https://discuss.frappe.io",
|
||||
"is_standard": 1,
|
||||
},
|
||||
{
|
||||
"item_label": "Frappe School",
|
||||
"item_label": _("Frappe School"),
|
||||
"item_type": "Route",
|
||||
"route": "https://frappe.io/school?utm_source=in_app",
|
||||
"is_standard": 1,
|
||||
},
|
||||
{
|
||||
"item_label": "Report an Issue",
|
||||
"item_label": _("Report an Issue"),
|
||||
"item_type": "Route",
|
||||
"route": "https://github.com/frappe/erpnext/issues",
|
||||
"is_standard": 1,
|
||||
@@ -319,26 +312,26 @@ def create_letter_head():
|
||||
|
||||
|
||||
DEFAULT_ROLE_PROFILES = {
|
||||
"Inventory": [
|
||||
_("Inventory"): [
|
||||
"Stock User",
|
||||
"Stock Manager",
|
||||
"Item Manager",
|
||||
],
|
||||
"Manufacturing": [
|
||||
_("Manufacturing"): [
|
||||
"Stock User",
|
||||
"Manufacturing User",
|
||||
"Manufacturing Manager",
|
||||
],
|
||||
"Accounts": [
|
||||
_("Accounts"): [
|
||||
"Accounts User",
|
||||
"Accounts Manager",
|
||||
],
|
||||
"Sales": [
|
||||
_("Sales"): [
|
||||
"Sales User",
|
||||
"Stock User",
|
||||
"Sales Manager",
|
||||
],
|
||||
"Purchase": [
|
||||
_("Purchase"): [
|
||||
"Item Manager",
|
||||
"Stock User",
|
||||
"Purchase User",
|
||||
|
||||
@@ -15,14 +15,7 @@ from frappe.utils import cstr, getdate
|
||||
|
||||
from erpnext.accounts.doctype.account.account import RootNotEditable
|
||||
from erpnext.regional.address_template.setup import set_up_address_templates
|
||||
|
||||
|
||||
def _(x, *args, **kwargs):
|
||||
"""Redefine the translation function to return the string as is.
|
||||
|
||||
We want to create english records but still mark the strings as translatable.
|
||||
The respective DocTypes have 'Translate Link Fields' enabled."""
|
||||
return x
|
||||
from erpnext.setup.utils import identity as _
|
||||
|
||||
|
||||
def read_lines(filename: str) -> list[str]:
|
||||
@@ -579,7 +572,7 @@ def create_bank_account(args, demo=False):
|
||||
return doc
|
||||
|
||||
except RootNotEditable:
|
||||
frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
|
||||
frappe.throw(frappe._("Bank account cannot be named as {0}").format(args.get("bank_account")))
|
||||
except frappe.DuplicateEntryError:
|
||||
# bank account same as a CoA entry
|
||||
pass
|
||||
|
||||
@@ -232,3 +232,15 @@ def welcome_email():
|
||||
site_name = get_default_company() or "ERPNext"
|
||||
title = _("Welcome to {0}").format(site_name)
|
||||
return title
|
||||
|
||||
|
||||
def identity(x, *args, **kwargs):
|
||||
"""Used for redefining the translation function to return the string as is.
|
||||
|
||||
We want to create english records but still mark the strings as translatable.
|
||||
E.g. when the respective DocTypes have 'Translate Link Fields' enabled or
|
||||
we're creating custom fields.
|
||||
|
||||
Use like this: `from erpnext.setup.utils import identity as _`
|
||||
"""
|
||||
return x
|
||||
|
||||
Reference in New Issue
Block a user