Merge pull request #50824 from khushi8112/move-accounts-freezing-setting-to-company

refactor: Move accounts freezing setting to company
This commit is contained in:
Khushi Rawat
2025-12-04 12:16:46 +05:30
committed by GitHub
21 changed files with 167 additions and 100 deletions

View File

@@ -95,6 +95,11 @@
"depreciation_cost_center",
"capital_work_in_progress_account",
"asset_received_but_not_billed",
"accounts_closing_tab",
"accounts_closing_section",
"accounts_frozen_till_date",
"column_break_tawz",
"role_allowed_for_frozen_entries",
"buying_and_selling_tab",
"sales_settings",
"default_buying_terms",
@@ -930,8 +935,36 @@
"fieldtype": "Link",
"label": "Default Sales Contact",
"options": "Contact"
},
{
"description": "Accounting entries are frozen up to this date. Only users with the specified role can create or modify entries before this date.",
"fieldname": "accounts_frozen_till_date",
"fieldtype": "Date",
"in_list_view": 1,
"label": "Accounts Frozen Till Date"
},
{
"fieldname": "accounts_closing_tab",
"fieldtype": "Tab Break",
"label": "Accounts Closing"
},
{
"fieldname": "column_break_tawz",
"fieldtype": "Column Break"
},
{
"fieldname": "role_allowed_for_frozen_entries",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Roles Allowed to Set and Edit Frozen Account Entries",
"options": "Role"
},
{
"fieldname": "accounts_closing_section",
"fieldtype": "Section Break"
}
],
"grid_page_length": 50,
"icon": "fa fa-building",
"idx": 1,
"image_field": "company_logo",

View File

@@ -19,6 +19,7 @@ from erpnext.accounts.doctype.financial_report_template.financial_report_templat
sync_financial_report_templates,
)
from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
from erpnext.stock.utils import check_pending_reposting
class Company(NestedSet):
@@ -31,6 +32,7 @@ class Company(NestedSet):
from frappe.types import DF
abbr: DF.Data
accounts_frozen_till_date: DF.Date | None
accumulated_depreciation_account: DF.Link | None
allow_account_creation_against_child_company: DF.Check
asset_received_but_not_billed: DF.Link | None
@@ -103,6 +105,7 @@ class Company(NestedSet):
registration_details: DF.Code | None
reporting_currency: DF.Link | None
rgt: DF.Int
role_allowed_for_frozen_entries: DF.Link | None
round_off_account: DF.Link | None
round_off_cost_center: DF.Link | None
round_off_for_opening: DF.Link | None
@@ -151,6 +154,7 @@ class Company(NestedSet):
return exists
def validate(self):
old_doc = self.get_doc_before_save()
self.update_default_account = False
if self.is_new():
self.update_default_account = True
@@ -169,6 +173,7 @@ class Company(NestedSet):
self.set_reporting_currency()
self.validate_inventory_account_settings()
self.cant_change_valuation_method()
self.validate_pending_reposts(old_doc)
def cant_change_valuation_method(self):
doc_before_save = self.get_doc_before_save()
@@ -597,6 +602,11 @@ class Company(NestedSet):
)
self.reporting_currency = parent_reporting_currency
def validate_pending_reposts(self, old_doc):
if old_doc and old_doc.accounts_frozen_till_date != self.accounts_frozen_till_date:
if self.accounts_frozen_till_date:
check_pending_reposting(self.accounts_frozen_till_date, self.name)
def set_default_accounts(self):
default_accounts = {
"default_cash_account": "Cash",