[minor] moved make_employee from Employee to Offer Letter

This commit is contained in:
Anand Doshi 2016-02-16 15:53:09 +05:30
parent 5e771c5678
commit 870d0441a8
3 changed files with 20 additions and 20 deletions

View File

@ -187,20 +187,6 @@ def make_salary_structure(source_name, target=None):
target.make_earn_ded_table()
return target
@frappe.whitelist()
def make_employee(source_name, target_doc=None):
def set_missing_values(source, target):
target.personal_email = frappe.db.get_value("Job Applicant", source.job_applicant, "email_id")
doc = get_mapped_doc("Offer Letter", source_name, {
"Offer Letter": {
"doctype": "Employee",
"field_map": {
"applicant_name": "employee_name",
}}
}, target_doc, set_missing_values)
return doc
def validate_employee_role(doc, method):
# called via User hook
if "Employee" in [d.role for d in doc.get("user_roles")]:

View File

@ -22,10 +22,9 @@ frappe.ui.form.on("Offer Letter", {
});
erpnext.offer_letter.make_employee = function(frm) {
frappe.model.open_mapped_doc({
method: "erpnext.hr.doctype.employee.employee.make_employee",
frm : frm
method: "erpnext.hr.doctype.offer_letter.offer_letter.make_employee",
frm: frm
});
}
};

View File

@ -4,6 +4,21 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
class OfferLetter(Document):
pass
@frappe.whitelist()
def make_employee(source_name, target_doc=None):
def set_missing_values(source, target):
target.personal_email = frappe.db.get_value("Job Applicant", source.job_applicant, "email_id")
doc = get_mapped_doc("Offer Letter", source_name, {
"Offer Letter": {
"doctype": "Employee",
"field_map": {
"applicant_name": "employee_name",
}}
}, target_doc, set_missing_values)
return doc