fix(patch): update naming series for budget

This commit is contained in:
khushi8112
2025-11-17 17:43:41 +05:30
parent 4abe2e82a0
commit e08793cb8f
4 changed files with 23 additions and 20 deletions

View File

@@ -188,7 +188,7 @@
"fieldtype": "Select",
"label": "Series",
"no_copy": 1,
"options": "BUDGET-.YYYY.-",
"options": "BUDGET-.########",
"print_hide": 1,
"reqd": 1,
"set_only_once": 1
@@ -308,7 +308,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-11-06 10:36:35.565701",
"modified": "2025-11-17 17:38:27.759355",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Budget",

View File

@@ -60,7 +60,7 @@ class Budget(Document):
distribute_equally: DF.Check
distribution_frequency: DF.Literal["Monthly", "Quarterly", "Half-Yearly", "Yearly"]
from_fiscal_year: DF.Link
naming_series: DF.Literal["BUDGET-.YYYY.-"]
naming_series: DF.Literal["BUDGET-.########"]
project: DF.Link | None
revision_of: DF.Data | None
to_fiscal_year: DF.Link

View File

@@ -448,4 +448,4 @@ erpnext.patches.v16_0.update_serial_batch_entries
erpnext.patches.v16_0.set_company_wise_warehouses
erpnext.patches.v16_0.set_valuation_method_on_companies
erpnext.patches.v15_0.migrate_old_item_wise_tax_detail_data_to_table
erpnext.patches.v16_0.migrate_submitted_budgets_to_new_structure
erpnext.patches.v16_0.migrate_budget_records_to_new_structure

View File

@@ -3,14 +3,14 @@ from frappe.utils import add_months, flt, get_first_day, get_last_day
def execute():
submitted_budgets = frappe.get_all("Budget", filters={"docstatus": 1}, pluck="name")
budgets = frappe.get_all("Budget", filters={"docstatus": ["in", [0, 1]]}, pluck="name")
for old_budget in submitted_budgets:
old_bud = frappe.get_doc("Budget", old_budget)
for budget in budgets:
old_budget = frappe.get_doc("Budget", budget)
old_accounts = frappe.get_all(
"Budget Account",
filters={"parent": old_bud.name},
filters={"parent": old_budget.name},
fields=["account", "budget_amount"],
order_by="idx asc",
)
@@ -19,10 +19,10 @@ def execute():
continue
old_distribution = []
if old_bud.monthly_distribution:
if old_budget.monthly_distribution:
old_distribution = frappe.get_all(
"Monthly Distribution Percentage",
filters={"parent": old_bud.monthly_distribution},
filters={"parent": old_budget.monthly_distribution},
fields=["percentage_allocation"],
order_by="idx asc",
)
@@ -32,16 +32,16 @@ def execute():
else:
percentage_list = [100 / 12] * 12
fy = frappe.get_doc("Fiscal Year", old_bud.fiscal_year)
fy = frappe.get_doc("Fiscal Year", old_budget.fiscal_year)
fy_start = fy.year_start_date
fy_end = fy.year_end_date
for acc in old_accounts:
new = frappe.new_doc("Budget")
new.company = old_bud.company
new.cost_center = old_bud.cost_center
new.project = old_bud.project
new.company = old_budget.company
new.cost_center = old_budget.cost_center
new.project = old_budget.project
new.fiscal_year = fy.name
new.from_fiscal_year = fy.name
@@ -71,8 +71,8 @@ def execute():
]
for field in fields_to_copy:
if hasattr(old_bud, field):
new.set(field, old_bud.get(field))
if hasattr(old_budget, field):
new.set(field, old_budget.get(field))
start = fy_start
for percentage in percentage_list:
@@ -92,11 +92,14 @@ def execute():
start = add_months(start, 1)
new.flags.ignore_validate = True
new.flags.ignore_mandatory = True
new.flags.ignore_links = True
new.flags.ignore_permissions = True
new.insert(ignore_permissions=True, ignore_mandatory=True)
new.submit()
old_bud.cancel()
if old_budget.docstatus == 1:
new.submit()
if old_budget.docstatus == 1:
old_budget.cancel()
else:
old_budget.delete()