feat(Asset): Add 'Create > Asset Repair' button

This commit is contained in:
GangaManoj 2021-05-10 21:09:13 +05:30
parent ed79b224cc
commit 322975a03c
2 changed files with 35 additions and 1 deletions

View File

@ -115,6 +115,15 @@ frappe.ui.form.on('Asset', {
frm.trigger("create_asset_maintenance");
}, __('Create'));
}
if (frm.doc.docstatus == 1) {
frm.add_custom_button(__("Asset Repair"), function() {
// frappe.model.open_mapped_doc({
// method: 'erpnext.stock.doctype.delivery_trip.delivery_trip.make_expense_claim',
// frm: cur_frm,
// });
frm.trigger("create_asset_repair");
}, __("Create"));
}
if (frm.doc.status != 'Fully Depreciated') {
frm.add_custom_button(__("Asset Value Adjustment"), function() {
frm.trigger("create_asset_adjustment");
@ -304,6 +313,21 @@ frappe.ui.form.on('Asset', {
})
},
create_asset_repair: function(frm) {
frappe.call({
args: {
"asset": frm.doc.name,
"item_code": frm.doc.item_code,
"item_name": frm.doc.item_name
},
method: "erpnext.assets.doctype.asset.asset.create_asset_repair",
callback: function(r) {
var doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
})
},
create_asset_adjustment: function(frm) {
frappe.call({
args: {

View File

@ -637,9 +637,19 @@ def create_asset_maintenance(asset, item_code, item_name, asset_category, compan
})
return asset_maintenance
@frappe.whitelist()
def create_asset_repair(asset, item_code, item_name):
asset_repair = frappe.new_doc("Asset Repair")
asset_repair.update({
"asset_name": asset,
"item_code": item_code,
"item_name": item_name
})
return asset_repair
@frappe.whitelist()
def create_asset_adjustment(asset, asset_category, company):
asset_maintenance = frappe.new_doc("Asset Value Adjustment")
asset_maintenance = frappe.get_doc("Asset Value Adjustment")
asset_maintenance.update({
"asset": asset,
"company": company,