mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
refactor: Ensure flag cleanup with try-finally to prevent state corruption
This commit is contained in:
@@ -493,15 +493,17 @@ class AssetCapitalization(StockController):
|
|||||||
|
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
frappe.flags.is_composite_component = True
|
frappe.flags.is_composite_component = True
|
||||||
notes = _(
|
try:
|
||||||
"This schedule was created when Asset {0} was consumed through Asset Capitalization {1}."
|
notes = _(
|
||||||
).format(
|
"This schedule was created when Asset {0} was consumed through Asset Capitalization {1}."
|
||||||
get_link_to_form(asset.doctype, asset.name),
|
).format(
|
||||||
get_link_to_form(self.doctype, self.get("name")),
|
get_link_to_form(asset.doctype, asset.name),
|
||||||
)
|
get_link_to_form(self.doctype, self.get("name")),
|
||||||
depreciate_asset(asset, self.posting_date, notes)
|
)
|
||||||
frappe.flags.is_composite_component = False
|
depreciate_asset(asset, self.posting_date, notes)
|
||||||
asset.reload()
|
asset.reload()
|
||||||
|
finally:
|
||||||
|
frappe.flags.is_composite_component = False
|
||||||
|
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
||||||
asset,
|
asset,
|
||||||
|
|||||||
Reference in New Issue
Block a user