From c2b0102852acc1d826fdf9bc01ca7c9a75dbca6b Mon Sep 17 00:00:00 2001 From: GangaManoj Date: Thu, 13 May 2021 00:58:07 +0530 Subject: [PATCH] feat(Asset Repair): Add 'View General Ledger' button --- erpnext/assets/doctype/asset_repair/asset_repair.js | 9 +++++++++ erpnext/assets/doctype/asset_repair/asset_repair.py | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js index 605edccc11..a5fda53429 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.js +++ b/erpnext/assets/doctype/asset_repair/asset_repair.js @@ -29,6 +29,15 @@ frappe.ui.form.on('Asset Repair', { refresh: function(frm) { frm.toggle_display(['completion_date', 'repair_status', 'accounting_details', 'accounting_dimensions_section'], !(frm.doc.__islocal)); frm.toggle_display(['stock_consumption_details_section'], frm.doc.stock_consumption) + + if (frm.doc.docstatus) { + frm.add_custom_button("View General Ledger", function() { + frappe.route_options = { + "voucher_no": frm.doc.name + }; + frappe.set_route("query-report", "General Ledger"); + }); + } }, repair_status: (frm) => { diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 343e6c4c9c..9c3d880eac 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -5,11 +5,10 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import time_diff_in_hours +from frappe.utils import time_diff_in_hours, getdate from frappe.model.document import Document from frappe.utils import flt from erpnext.accounts.general_ledger import make_gl_entries -from erpnext.controllers.accounts_controller import AccountsController class AssetRepair(Document): def validate(self): @@ -66,7 +65,8 @@ class AssetRepair(Document): "against": repair_and_maintenance_account, "voucher_type": self.doctype, "voucher_no": self.name, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "posting_date": getdate() }) gl_entry.insert() gl_entry = frappe.get_doc({ @@ -77,7 +77,8 @@ class AssetRepair(Document): "against": self.payable_account, "voucher_type": self.doctype, "voucher_no": self.name, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "posting_date": getdate() }) gl_entry.insert()