mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-21 07:38:29 +00:00
fix(UI): improve asset action buttons group
(cherry picked from commit e90a3b5a56)
This commit is contained in:
@@ -86,47 +86,44 @@ frappe.ui.form.on("Asset", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: async function (frm) {
|
||||||
frappe.ui.form.trigger("Asset", "asset_type");
|
frappe.ui.form.trigger("Asset", "asset_type");
|
||||||
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
||||||
|
|
||||||
|
let has_create_buttons = false;
|
||||||
if (frm.doc.docstatus == 1) {
|
if (frm.doc.docstatus == 1) {
|
||||||
if (["Submitted", "Partially Depreciated", "Fully Depreciated"].includes(frm.doc.status)) {
|
if (["Submitted", "Partially Depreciated"].includes(frm.doc.status)) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Transfer Asset"),
|
__("Asset Value Adjustment"),
|
||||||
function () {
|
function () {
|
||||||
erpnext.asset.transfer_asset(frm);
|
frm.trigger("create_asset_value_adjustment");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Create")
|
||||||
);
|
);
|
||||||
|
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Scrap Asset"),
|
__("Asset Repair"),
|
||||||
function () {
|
function () {
|
||||||
erpnext.asset.scrap_asset(frm);
|
frm.trigger("create_asset_repair");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Create")
|
||||||
);
|
);
|
||||||
|
has_create_buttons = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!frm.doc.calculate_depreciation) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Sell Asset"),
|
__("Depreciation Entry"),
|
||||||
function () {
|
function () {
|
||||||
frm.trigger("sell_asset");
|
frm.trigger("make_journal_entry");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Create")
|
||||||
);
|
);
|
||||||
|
has_create_buttons = true;
|
||||||
|
}
|
||||||
|
|
||||||
frm.add_custom_button(
|
if (has_create_buttons) {
|
||||||
__("Split Asset"),
|
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
function () {
|
|
||||||
frm.trigger("split_asset");
|
|
||||||
},
|
|
||||||
__("Manage")
|
|
||||||
);
|
|
||||||
} else if (frm.doc.status == "Scrapped") {
|
|
||||||
frm.add_custom_button(__("Restore Asset"), function () {
|
|
||||||
erpnext.asset.restore_asset(frm);
|
|
||||||
}).addClass("btn-primary");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.maintenance_required && !frm.doc.maintenance_schedule) {
|
if (frm.doc.maintenance_required && !frm.doc.maintenance_schedule) {
|
||||||
@@ -135,41 +132,51 @@ frappe.ui.form.on("Asset", {
|
|||||||
function () {
|
function () {
|
||||||
frm.trigger("create_asset_maintenance");
|
frm.trigger("create_asset_maintenance");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Actions")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["Submitted", "Partially Depreciated"].includes(frm.doc.status)) {
|
if (["Submitted", "Partially Depreciated", "Fully Depreciated"].includes(frm.doc.status)) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Adjust Asset Value"),
|
__("Split Asset"),
|
||||||
function () {
|
function () {
|
||||||
frm.trigger("create_asset_value_adjustment");
|
frm.trigger("split_asset");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Actions")
|
||||||
);
|
);
|
||||||
|
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Repair Asset"),
|
__("Transfer Asset"),
|
||||||
function () {
|
function () {
|
||||||
frm.trigger("create_asset_repair");
|
erpnext.asset.transfer_asset(frm);
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("Actions")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
frm.add_custom_button(
|
||||||
|
__("Scrap Asset"),
|
||||||
|
function () {
|
||||||
|
erpnext.asset.scrap_asset(frm);
|
||||||
|
},
|
||||||
|
__("Actions")
|
||||||
|
);
|
||||||
|
|
||||||
|
frm.add_custom_button(
|
||||||
|
__("Sell Asset"),
|
||||||
|
function () {
|
||||||
|
frm.trigger("sell_asset");
|
||||||
|
},
|
||||||
|
__("Actions")
|
||||||
|
);
|
||||||
|
} else if (frm.doc.status == "Scrapped") {
|
||||||
|
frm.add_custom_button(__("Restore Asset"), function () {
|
||||||
|
erpnext.asset.restore_asset(frm);
|
||||||
|
}).addClass("btn-primary");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frm.doc.calculate_depreciation) {
|
if (await frm.events.should_show_accounting_ledger(frm)) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Create Depreciation Entry"),
|
__("Accounting Ledger"),
|
||||||
function () {
|
|
||||||
frm.trigger("make_journal_entry");
|
|
||||||
},
|
|
||||||
__("Manage")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frm.doc.purchase_receipt || !frm.doc.asset_type == "Existing Asset") {
|
|
||||||
frm.add_custom_button(
|
|
||||||
__("View General Ledger"),
|
|
||||||
function () {
|
function () {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
voucher_no: frm.doc.name,
|
voucher_no: frm.doc.name,
|
||||||
@@ -179,7 +186,7 @@ frappe.ui.form.on("Asset", {
|
|||||||
};
|
};
|
||||||
frappe.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
},
|
},
|
||||||
__("Manage")
|
__("View")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +224,27 @@ frappe.ui.form.on("Asset", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
should_show_accounting_ledger: async function (frm) {
|
||||||
|
if (["Capitalized"].includes(frm.doc.status)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!frm.doc.purchase_receipt &&
|
||||||
|
["Existing Asset", "Composite Component"].includes(frm.doc.asset_type)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const asset_category = await frappe.db.get_value(
|
||||||
|
"Asset Category",
|
||||||
|
frm.doc.asset_category,
|
||||||
|
"enable_cwip_accounting"
|
||||||
|
);
|
||||||
|
|
||||||
|
return !!asset_category.message?.enable_cwip_accounting;
|
||||||
|
},
|
||||||
|
|
||||||
set_depr_posting_failure_alert: function (frm) {
|
set_depr_posting_failure_alert: function (frm) {
|
||||||
const alert = `
|
const alert = `
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -9,18 +9,17 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"naming_series",
|
"naming_series",
|
||||||
|
"company",
|
||||||
"item_code",
|
"item_code",
|
||||||
|
"item_name",
|
||||||
"asset_name",
|
"asset_name",
|
||||||
"asset_category",
|
|
||||||
"location",
|
|
||||||
"image",
|
"image",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"company",
|
"location",
|
||||||
"asset_owner",
|
"asset_category",
|
||||||
"asset_owner_company",
|
|
||||||
"customer",
|
|
||||||
"supplier",
|
|
||||||
"asset_type",
|
"asset_type",
|
||||||
|
"maintenance_required",
|
||||||
|
"calculate_depreciation",
|
||||||
"purchase_details_section",
|
"purchase_details_section",
|
||||||
"purchase_receipt",
|
"purchase_receipt",
|
||||||
"purchase_receipt_item",
|
"purchase_receipt_item",
|
||||||
@@ -34,25 +33,38 @@
|
|||||||
"purchase_amount",
|
"purchase_amount",
|
||||||
"asset_quantity",
|
"asset_quantity",
|
||||||
"additional_asset_cost",
|
"additional_asset_cost",
|
||||||
|
"section_break_uiyd",
|
||||||
|
"column_break_bbwr",
|
||||||
|
"column_break_bfkm",
|
||||||
"total_asset_cost",
|
"total_asset_cost",
|
||||||
"depreciation_tab",
|
"depreciation_tab",
|
||||||
"calculate_depreciation",
|
"column_break_wqzi",
|
||||||
"column_break_33",
|
|
||||||
"opening_accumulated_depreciation",
|
"opening_accumulated_depreciation",
|
||||||
"opening_number_of_booked_depreciations",
|
|
||||||
"is_fully_depreciated",
|
"is_fully_depreciated",
|
||||||
|
"column_break_33",
|
||||||
|
"opening_number_of_booked_depreciations",
|
||||||
"section_break_36",
|
"section_break_36",
|
||||||
"finance_books",
|
"finance_books",
|
||||||
"section_break_33",
|
"section_break_33",
|
||||||
"depreciation_method",
|
"depreciation_method",
|
||||||
"value_after_depreciation",
|
"value_after_depreciation",
|
||||||
"total_number_of_depreciations",
|
|
||||||
"column_break_24",
|
|
||||||
"frequency_of_depreciation",
|
"frequency_of_depreciation",
|
||||||
|
"column_break_24",
|
||||||
"next_depreciation_date",
|
"next_depreciation_date",
|
||||||
|
"total_number_of_depreciations",
|
||||||
"depreciation_schedule_sb",
|
"depreciation_schedule_sb",
|
||||||
"depreciation_schedule_view",
|
"depreciation_schedule_view",
|
||||||
"insurance_details_tab",
|
"other_info_tab",
|
||||||
|
"accounting_dimensions_section",
|
||||||
|
"cost_center",
|
||||||
|
"column_break_rjyw",
|
||||||
|
"asset_owner_section",
|
||||||
|
"asset_owner",
|
||||||
|
"column_break_yeds",
|
||||||
|
"asset_owner_company",
|
||||||
|
"customer",
|
||||||
|
"supplier",
|
||||||
|
"insurance_section",
|
||||||
"policy_number",
|
"policy_number",
|
||||||
"insurer",
|
"insurer",
|
||||||
"insured_value",
|
"insured_value",
|
||||||
@@ -60,21 +72,17 @@
|
|||||||
"insurance_start_date",
|
"insurance_start_date",
|
||||||
"insurance_end_date",
|
"insurance_end_date",
|
||||||
"comprehensive_insurance",
|
"comprehensive_insurance",
|
||||||
"other_info_tab",
|
|
||||||
"accounting_dimensions_section",
|
|
||||||
"cost_center",
|
|
||||||
"section_break_jtou",
|
"section_break_jtou",
|
||||||
"status",
|
"status",
|
||||||
"custodian",
|
"custodian",
|
||||||
|
"department",
|
||||||
"default_finance_book",
|
"default_finance_book",
|
||||||
"depr_entry_posting_status",
|
"depr_entry_posting_status",
|
||||||
"booked_fixed_asset",
|
|
||||||
"column_break_51",
|
"column_break_51",
|
||||||
"department",
|
|
||||||
"split_from",
|
|
||||||
"journal_entry_for_scrap",
|
"journal_entry_for_scrap",
|
||||||
|
"split_from",
|
||||||
"amended_from",
|
"amended_from",
|
||||||
"maintenance_required",
|
"booked_fixed_asset",
|
||||||
"connections_tab"
|
"connections_tab"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@@ -246,13 +254,14 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "section_break_33",
|
"fieldname": "section_break_33",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 1
|
"hidden": 1,
|
||||||
|
"label": "Depreciation Details"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "depreciation_method",
|
"fieldname": "depreciation_method",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Depreciation Method",
|
"label": "Depreciation Method",
|
||||||
"options": "\nStraight Line\nDouble Declining Balance\nManual"
|
"options": "\nStraight Line\nDouble Declining Balance\nWritten Down Value\nManual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "value_after_depreciation",
|
"fieldname": "value_after_depreciation",
|
||||||
@@ -279,6 +288,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "next_depreciation_date",
|
"fieldname": "next_depreciation_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Next Depreciation Date",
|
"label": "Next Depreciation Date",
|
||||||
"no_copy": 1
|
"no_copy": 1
|
||||||
},
|
},
|
||||||
@@ -397,7 +407,7 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "calculate_depreciation",
|
"depends_on": "eval: doc.calculate_depreciation",
|
||||||
"fieldname": "section_break_36",
|
"fieldname": "section_break_36",
|
||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
},
|
},
|
||||||
@@ -441,6 +451,7 @@
|
|||||||
"depends_on": "eval:(doc.asset_type == \"Existing Asset\")",
|
"depends_on": "eval:(doc.asset_type == \"Existing Asset\")",
|
||||||
"fieldname": "is_fully_depreciated",
|
"fieldname": "is_fully_depreciated",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Is Fully Depreciated"
|
"label": "Is Fully Depreciated"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -489,15 +500,10 @@
|
|||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "Purchase Invoice Item"
|
"label": "Purchase Invoice Item"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "insurance_details_tab",
|
|
||||||
"fieldtype": "Tab Break",
|
|
||||||
"label": "Insurance"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "other_info_tab",
|
"fieldname": "other_info_tab",
|
||||||
"fieldtype": "Tab Break",
|
"fieldtype": "Tab Break",
|
||||||
"label": "Other Info"
|
"label": "More Info"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "connections_tab",
|
"fieldname": "connections_tab",
|
||||||
@@ -506,6 +512,7 @@
|
|||||||
"show_dashboard": 1
|
"show_dashboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval: doc.calculate_depreciation || doc.asset_type == \"Existing Asset\"",
|
||||||
"fieldname": "depreciation_tab",
|
"fieldname": "depreciation_tab",
|
||||||
"fieldtype": "Tab Break",
|
"fieldtype": "Tab Break",
|
||||||
"label": "Depreciation"
|
"label": "Depreciation"
|
||||||
@@ -533,6 +540,48 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Asset Type",
|
"label": "Asset Type",
|
||||||
"options": "\nExisting Asset\nComposite Asset\nComposite Component"
|
"options": "\nExisting Asset\nComposite Asset\nComposite Component"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_wqzi",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_rjyw",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "insurance_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Insurance"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_uiyd",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_bbwr",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_bfkm",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "item_code.item_name",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Read Only",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Item Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "asset_owner_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Ownership"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_yeds",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
@@ -576,7 +625,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2026-02-03 15:48:13.407835",
|
"modified": "2026-02-05 12:42:45.350216",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ class Asset(AccountsController):
|
|||||||
default_finance_book: DF.Link | None
|
default_finance_book: DF.Link | None
|
||||||
department: DF.Link | None
|
department: DF.Link | None
|
||||||
depr_entry_posting_status: DF.Literal["", "Successful", "Failed"]
|
depr_entry_posting_status: DF.Literal["", "Successful", "Failed"]
|
||||||
depreciation_method: DF.Literal["", "Straight Line", "Double Declining Balance", "Manual"]
|
depreciation_method: DF.Literal[
|
||||||
|
"", "Straight Line", "Double Declining Balance", "Written Down Value", "Manual"
|
||||||
|
]
|
||||||
disposal_date: DF.Date | None
|
disposal_date: DF.Date | None
|
||||||
finance_books: DF.Table[AssetFinanceBook]
|
finance_books: DF.Table[AssetFinanceBook]
|
||||||
frequency_of_depreciation: DF.Int
|
frequency_of_depreciation: DF.Int
|
||||||
@@ -79,6 +81,7 @@ class Asset(AccountsController):
|
|||||||
insurer: DF.Data | None
|
insurer: DF.Data | None
|
||||||
is_fully_depreciated: DF.Check
|
is_fully_depreciated: DF.Check
|
||||||
item_code: DF.Link
|
item_code: DF.Link
|
||||||
|
item_name: DF.ReadOnly | None
|
||||||
journal_entry_for_scrap: DF.Link | None
|
journal_entry_for_scrap: DF.Link | None
|
||||||
location: DF.Link
|
location: DF.Link
|
||||||
maintenance_required: DF.Check
|
maintenance_required: DF.Check
|
||||||
|
|||||||
Reference in New Issue
Block a user