Skip to content

Commit

Permalink
Merge pull request #29350 from deepeshgarg007/asset_split
Browse files Browse the repository at this point in the history
feat: Splitting group assets
  • Loading branch information
deepeshgarg007 authored Jan 29, 2022
2 parents 36882f3 + 4d87465 commit eba0621
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 129 deletions.
41 changes: 41 additions & 0 deletions erpnext/assets/doctype/asset/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ frappe.ui.form.on('Asset', {
frm.trigger("create_asset_repair");
}, __("Manage"));

frm.add_custom_button(__("Split Asset"), function() {
frm.trigger("split_asset");
}, __("Manage"));

if (frm.doc.status != 'Fully Depreciated') {
frm.add_custom_button(__("Adjust Asset Value"), function() {
frm.trigger("create_asset_value_adjustment");
Expand Down Expand Up @@ -322,6 +326,43 @@ frappe.ui.form.on('Asset', {
});
},

split_asset: function(frm) {
const title = __('Split Asset');

const fields = [
{
fieldname: 'split_qty',
fieldtype: 'Int',
label: __('Split Qty'),
reqd: 1
}
];

let dialog = new frappe.ui.Dialog({
title: title,
fields: fields
});

dialog.set_primary_action(__('Split'), function() {
const dialog_data = dialog.get_values();
frappe.call({
args: {
"asset_name": frm.doc.name,
"split_qty": cint(dialog_data.split_qty)
},
method: "erpnext.assets.doctype.asset.asset.split_asset",
callback: function(r) {
let doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
});

dialog.hide();
});

dialog.show();
},

create_asset_value_adjustment: function(frm) {
frappe.call({
args: {
Expand Down
12 changes: 10 additions & 2 deletions erpnext/assets/doctype/asset/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2016-03-01 17:01:27.920130",
"creation": "2022-01-18 02:26:55.975005",
"doctype": "DocType",
"document_type": "Document",
"engine": "InnoDB",
Expand All @@ -23,6 +23,7 @@
"asset_name",
"asset_category",
"location",
"split_from",
"custodian",
"department",
"disposal_date",
Expand Down Expand Up @@ -482,6 +483,13 @@
"fieldtype": "Section Break",
"label": "Finance Books"
},
{
"fieldname": "split_from",
"fieldtype": "Link",
"label": "Split From",
"options": "Asset",
"read_only": 1
},
{
"fieldname": "asset_quantity",
"fieldtype": "Int",
Expand Down Expand Up @@ -509,7 +517,7 @@
"link_fieldname": "asset"
}
],
"modified": "2022-01-18 12:57:36.741192",
"modified": "2022-01-20 12:57:36.741192",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
Expand Down
Loading

0 comments on commit eba0621

Please sign in to comment.