Merge pull request #56569 from frappe/fix-asset-is-fully-depreciated-visibility

fix(asset): conditionally show Is Fully Depreciated field
This commit is contained in:
Khushi Rawat
2026-06-30 12:28:22 +05:30
committed by GitHub
3 changed files with 16 additions and 2 deletions

View File

@@ -93,6 +93,11 @@ frappe.ui.form.on("Asset", {
frappe.ui.form.trigger("Asset", "asset_type");
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
if (frm.doc.docstatus < 1 && frm.doc.calculate_depreciation && frm.doc.is_fully_depreciated) {
// Is Fully Depreciated is read-only while depreciation is calculated, so keep it unchecked
frm.set_value("is_fully_depreciated", 0);
}
let has_create_buttons = false;
if (frm.doc.docstatus == 1) {
if (["Submitted", "Partially Depreciated"].includes(frm.doc.status)) {
@@ -727,6 +732,10 @@ frappe.ui.form.on("Asset", {
calculate_depreciation: function (frm) {
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
if (frm.doc.calculate_depreciation && frm.doc.is_fully_depreciated) {
// Is Fully Depreciated is read-only while depreciation is calculated, so keep it unchecked
frm.set_value("is_fully_depreciated", 0);
}
if (frm.doc.item_code && frm.doc.calculate_depreciation && frm.doc.net_purchase_amount) {
frm.trigger("set_finance_book");
} else {

View File

@@ -450,10 +450,11 @@
},
{
"default": "0",
"depends_on": "eval:(doc.asset_type == \"Existing Asset\" && !doc.calculate_depreciation) || doc.calculate_depreciation",
"fieldname": "is_fully_depreciated",
"fieldtype": "Check",
"hidden": 1,
"label": "Is Fully Depreciated"
"label": "Is Fully Depreciated",
"read_only_depends_on": "eval:doc.calculate_depreciation"
},
{
"depends_on": "eval:doc.docstatus > 0",

View File

@@ -132,6 +132,10 @@ class Asset(AccountsController):
self.validate_gross_and_purchase_amount()
self.validate_finance_books()
if self.calculate_depreciation:
# Is Fully Depreciated is only applicable to manually entered existing assets
self.is_fully_depreciated = 0
def before_save(self):
self.total_asset_cost = self.net_purchase_amount + self.additional_asset_cost
self.status = self.get_status()