mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge pull request #51205 from khushi8112/do-not-disable-primary-action-button
fix: do not hide primary-action for composite asset
This commit is contained in:
@@ -80,6 +80,12 @@ frappe.ui.form.on("Asset", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
before_submit: function (frm) {
|
||||||
|
if (frm.doc.is_composite_asset && !frm.has_active_capitalization) {
|
||||||
|
frappe.throw(__("Please capitalize this asset before submitting."));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
frappe.ui.form.trigger("Asset", "is_existing_asset");
|
frappe.ui.form.trigger("Asset", "is_existing_asset");
|
||||||
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
||||||
@@ -196,9 +202,10 @@ frappe.ui.form.on("Asset", {
|
|||||||
asset: frm.doc.name,
|
asset: frm.doc.name,
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
|
frm.has_active_capitalization = r.message;
|
||||||
|
|
||||||
if (!r.message) {
|
if (!r.message) {
|
||||||
$(".primary-action").prop("hidden", true);
|
$(".form-message").text(__("Capitalize this asset before submitting."));
|
||||||
$(".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");
|
||||||
@@ -470,7 +477,6 @@ frappe.ui.form.on("Asset", {
|
|||||||
is_composite_asset: function (frm) {
|
is_composite_asset: function (frm) {
|
||||||
if (frm.doc.is_composite_asset) {
|
if (frm.doc.is_composite_asset) {
|
||||||
frm.set_value("net_purchase_amount", 0);
|
frm.set_value("net_purchase_amount", 0);
|
||||||
frm.set_df_property("net_purchase_amount", "read_only", 1);
|
|
||||||
} else {
|
} else {
|
||||||
frm.set_df_property("net_purchase_amount", "read_only", 0);
|
frm.set_df_property("net_purchase_amount", "read_only", 0);
|
||||||
}
|
}
|
||||||
@@ -538,7 +544,6 @@ frappe.ui.form.on("Asset", {
|
|||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
var doclist = frappe.model.sync(r.message);
|
var doclist = frappe.model.sync(r.message);
|
||||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||||
$(".primary-action").prop("hidden", false);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -556,7 +556,8 @@
|
|||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Net Purchase Amount",
|
"label": "Net Purchase Amount",
|
||||||
"mandatory_depends_on": "eval:(!doc.is_composite_asset || doc.docstatus==1)",
|
"mandatory_depends_on": "eval:(!doc.is_composite_asset || doc.docstatus==1)",
|
||||||
"options": "Company:company:default_currency"
|
"options": "Company:company:default_currency",
|
||||||
|
"read_only_depends_on": "eval: doc.is_composite_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
@@ -600,7 +601,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2025-11-04 22:39:00.817405",
|
"modified": "2025-12-18 16:36:40.904246",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ class Asset(AccountsController):
|
|||||||
self.validate_expected_value_after_useful_life()
|
self.validate_expected_value_after_useful_life()
|
||||||
self.set_total_booked_depreciations()
|
self.set_total_booked_depreciations()
|
||||||
|
|
||||||
|
def before_submit(self):
|
||||||
|
if self.is_composite_asset and not has_active_capitalization(self.name):
|
||||||
|
frappe.throw(_("Please capitalize this asset before submitting."))
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.validate_in_use_date()
|
self.validate_in_use_date()
|
||||||
self.make_asset_movement()
|
self.make_asset_movement()
|
||||||
|
|||||||
Reference in New Issue
Block a user