mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
when saving employee add employee image to profile
This commit is contained in:
@@ -73,14 +73,14 @@ class DocType:
|
|||||||
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
|
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
|
||||||
|
|
||||||
def update_profile(self):
|
def update_profile(self):
|
||||||
profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id)
|
|
||||||
|
|
||||||
# add employee role if missing
|
# add employee role if missing
|
||||||
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
|
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
|
||||||
where parent=%s""", self.doc.user_id):
|
where parent=%s""", self.doc.user_id):
|
||||||
from core.doctype.profile.profile import add_role
|
from core.doctype.profile.profile import add_role
|
||||||
add_role(self.doc.user_id, "HR User")
|
add_role(self.doc.user_id, "HR User")
|
||||||
|
|
||||||
|
profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id)
|
||||||
|
|
||||||
# copy details like Fullname, DOB and Image to Profile
|
# copy details like Fullname, DOB and Image to Profile
|
||||||
if self.doc.employee_name:
|
if self.doc.employee_name:
|
||||||
employee_name = self.doc.employee_name.split(" ")
|
employee_name = self.doc.employee_name.split(" ")
|
||||||
@@ -98,6 +98,19 @@ class DocType:
|
|||||||
if self.doc.gender:
|
if self.doc.gender:
|
||||||
profile_wrapper.doc.gender = self.doc.gender
|
profile_wrapper.doc.gender = self.doc.gender
|
||||||
|
|
||||||
|
if self.doc.image and self.doc.file_list:
|
||||||
|
# add to file list and user_image
|
||||||
|
for file_args in self.doc.file_list.split("\n"):
|
||||||
|
fname, fid = file_args.split(",")
|
||||||
|
if self.doc.image == fname:
|
||||||
|
new_file_args = fname + "," + fid
|
||||||
|
file_list = profile_wrapper.doc.file_list.split("\n")
|
||||||
|
if new_file_args not in file_list:
|
||||||
|
file_list += [new_file_args]
|
||||||
|
profile_wrapper.doc.file_list = "\n".join(file_list)
|
||||||
|
profile_wrapper.doc.user_image = fname
|
||||||
|
break
|
||||||
|
|
||||||
profile_wrapper.save()
|
profile_wrapper.save()
|
||||||
|
|
||||||
def validate_date(self):
|
def validate_date(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user