feat(Asset Repair): Add 'View General Ledger' button
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js
index 605edcc..a5fda53 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.js
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.js
@@ -29,6 +29,15 @@
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 343e6c4..9c3d880 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 @@
"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 @@
"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()