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 |
Anand Doshi | 6ad06f3 | 2013-02-18 19:57:16 +0530 | [diff] [blame^] | 6 | from webnotes.model.doc import copy_common_fields |
Anand Doshi | ac1985f | 2013-02-18 19:42:02 +0530 | [diff] [blame] | 7 | |
| 8 | def update_employee_details(controller, method=None): |
| 9 | """update employee details in linked doctypes""" |
| 10 | if method == "on_update" and controller.doc.doctype == "Employee": |
| 11 | # update salary structure |
| 12 | active_salary_structure = webnotes.conn.get_value("Salary Structure", |
| 13 | {"is_active": "Yes", "employee": controller.doc.name}) |
| 14 | if not active_salary_structure: |
| 15 | return |
| 16 | |
| 17 | ss = webnotes.model_wrapper("Salary Structure", active_salary_structure) |
Anand Doshi | 6ad06f3 | 2013-02-18 19:57:16 +0530 | [diff] [blame^] | 18 | copy_common_fields(controller.doc, ss.doc) |
| 19 | ss.save() |