Skip to content

Commit

Permalink
Merge pull request #40121 from nabinhait/asset-cancel-deletion
Browse files Browse the repository at this point in the history
fix: Patch to remove cancelled asset capitalization from asset
  • Loading branch information
nabinhait authored Mar 11, 2024
2 parents cde5b93 + 1951f71 commit d2b34ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def on_cancel(self):
self.make_gl_entries()
self.restore_consumed_asset_items()

def on_trash(self):
frappe.db.set_value("Asset", self.target_asset, "capitalized_in", None)
super(AssetCapitalization, self).on_trash()

def cancel_target_asset(self):
if self.entry_type == "Capitalization" and self.target_asset:
asset_doc = frappe.get_doc("Asset", self.target_asset)
Expand Down
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,5 @@ erpnext.patches.v14_0.create_accounting_dimensions_in_reconciliation_tool
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
erpnext.stock.doctype.delivery_note.patches.drop_unused_return_against_index # 2023-12-20
erpnext.patches.v14_0.set_maintain_stock_for_bom_item
erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records
erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records
erpnext.patches.v15_0.remove_cancelled_asset_capitalization_from_asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import frappe


def execute():
cancelled_asset_capitalizations = frappe.get_all(
"Asset Capitalization",
filters={"docstatus": 2},
fields=["name", "target_asset"],
)
for asset_capitalization in cancelled_asset_capitalizations:
frappe.db.set_value("Asset", asset_capitalization.target_asset, "capitalized_in", None)

0 comments on commit d2b34ea

Please sign in to comment.