mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 15:32:14 +00:00
fix: disable primary action button only when there are no active capitalization
(cherry picked from commit bb877f4a6b)
This commit is contained in:
@@ -188,11 +188,21 @@ frappe.ui.form.on("Asset", {
|
|||||||
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
|
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
|
||||||
|
|
||||||
if (frm.doc.is_composite_asset) {
|
if (frm.doc.is_composite_asset) {
|
||||||
$(".primary-action").prop("hidden", true);
|
frappe.call({
|
||||||
$(".form-message").text("Capitalize this asset to confirm");
|
method: "erpnext.assets.doctype.asset.asset.has_active_capitalization",
|
||||||
|
args: {
|
||||||
|
asset: frm.doc.name,
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
if (!r.message) {
|
||||||
|
$(".primary-action").prop("hidden", true);
|
||||||
|
$(".form-message").text("Capitalize this asset to confirm");
|
||||||
|
|
||||||
frm.add_custom_button(__("Capitalize Asset"), function () {
|
frm.add_custom_button(__("Capitalize Asset"), function () {
|
||||||
frm.trigger("create_asset_capitalization");
|
frm.trigger("create_asset_capitalization");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,6 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.is_composite_asset",
|
|
||||||
"fieldname": "gross_purchase_amount",
|
"fieldname": "gross_purchase_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Gross Purchase Amount",
|
"label": "Gross Purchase Amount",
|
||||||
@@ -580,7 +579,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2024-07-07 22:27:14.733839",
|
"modified": "2024-08-01 16:39:09.340973",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@@ -1035,6 +1035,14 @@ def get_asset_value_after_depreciation(asset_name, finance_book=None):
|
|||||||
return asset.get_value_after_depreciation(finance_book)
|
return asset.get_value_after_depreciation(finance_book)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def has_active_capitalization(asset):
|
||||||
|
active_capitalizations = frappe.db.count(
|
||||||
|
"Asset Capitalization", filters={"target_asset": asset, "docstatus": 1}
|
||||||
|
)
|
||||||
|
return active_capitalizations > 0
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def split_asset(asset_name, split_qty):
|
def split_asset(asset_name, split_qty):
|
||||||
asset = frappe.get_doc("Asset", asset_name)
|
asset = frappe.get_doc("Asset", asset_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user