Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handling circular linking while cancelling asset capitalization #39814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion erpnext/assets/doctype/asset/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ frappe.ui.form.on('Asset', {
},

make_schedules_editable: function(frm) {
if (frm.doc.finance_books.length) {
if (frm.doc.finance_books && frm.doc.finance_books.length) {
var is_manual_hence_editable = frm.doc.finance_books.filter(d => d.depreciation_method == "Manual").length > 0
? true : false;
var is_shift_hence_editable = frm.doc.finance_books.filter(d => d.shift_based).length > 0
Expand Down
2 changes: 1 addition & 1 deletion erpnext/assets/doctype/asset/depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def modify_depreciation_schedule_for_asset_repairs(asset):


def reverse_depreciation_entry_made_after_disposal(asset, date):
if not asset.calculate_depreciation:
if not asset.calculate_depreciation or not asset.get("schedules"):
return

row = -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ frappe.provide("erpnext.assets");
erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.stock.StockController {
setup() {
this.setup_posting_date_time_check();
this.frm.ignore_doctypes_on_cancel_all = ["Asset Movement"];
}

onload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ def on_cancel(self):
"Stock Ledger Entry",
"Repost Item Valuation",
"Asset",
"Asset Movement"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres a comma missing here, as indicated by the linter failure on this PR. After merging without fixing this, the linter fails for all other PRs 😢 .

)
self.cancel_target_asset()
self.update_stock_ledger()
self.make_gl_entries()
self.restore_consumed_asset_items()

def cancel_target_asset(self):
if self.entry_type == "Capitalization" and self.target_asset:
asset_doc = frappe.get_doc("Asset", self.target_asset)
asset_doc.db_set("capitalized_in", None)
if asset_doc.docstatus == 1:
asset_doc.cancel()

Expand Down
Loading