Anand Doshi | ac1985f | 2013-02-18 19:42:02 +0530 | [diff] [blame^] | 1 | # ERPNext - web based ERP (http://erpnext.com) |
| 2 | # For license information, please see license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
| 6 | |
| 7 | def update_employee_details(controller, method=None): |
| 8 | """update employee details in linked doctypes""" |
| 9 | if method == "on_update" and controller.doc.doctype == "Employee": |
| 10 | # update salary structure |
| 11 | active_salary_structure = webnotes.conn.get_value("Salary Structure", |
| 12 | {"is_active": "Yes", "employee": controller.doc.name}) |
| 13 | if not active_salary_structure: |
| 14 | return |
| 15 | |
| 16 | ss = webnotes.model_wrapper("Salary Structure", active_salary_structure) |
| 17 | ss_doctype = webnotes.get_doctype("Salary Structure") |
| 18 | update = False |
| 19 | for fieldname, value in controller.doc.fields.items(): |
| 20 | if ss_doctype.get_field(fieldname) and ss.doc.fields[fieldname] != value: |
| 21 | ss.doc.fields[fieldname] = value |
| 22 | update = True |
| 23 | |
| 24 | if update: |
| 25 | ss.save() |
| 26 | |
| 27 | |