Improved code
diff --git a/erpnext/hr/doctype/offer_letter/offer_letter.js b/erpnext/hr/doctype/offer_letter/offer_letter.js
index 552a9f0..526833a 100755
--- a/erpnext/hr/doctype/offer_letter/offer_letter.js
+++ b/erpnext/hr/doctype/offer_letter/offer_letter.js
@@ -1,6 +1,8 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
+frappe.provide("erpnext.offer_letter");
+
frappe.ui.form.on("Offer Letter", {
select_terms: function(frm) {
frappe.model.get_value("Terms and Conditions", frm.doc.select_terms, "terms", function(value) {
@@ -10,16 +12,20 @@
refresh:function(frm){
if((!frm.doc.__islocal) && (frm.doc.status=='Accepted') && (frm.doc.docstatus===1)){
- frm.add_custom_button(__('Make Employee'),
- frm.cscript['Make Employee']);
- }
-}
+ frm.add_custom_button(__('Make Employee'),
+ function() {
+ erpnext.offer_letter.make_employee(frm)
+ }
+ );
+ }
+ }
+
});
-cur_frm.cscript['Make Employee'] = function() {
-frappe.model.open_mapped_doc({
- method: "erpnext.hr.doctype.employee.employee.make_employee",
- frm : cur_frm
-});
+erpnext.offer_letter.make_employee = function(frm) {
+ frappe.model.open_mapped_doc({
+ method: "erpnext.hr.doctype.employee.employee.make_employee",
+ frm : frm
+ });
}
\ No newline at end of file