From c643c8bb39a21d8b9ffac69f13c908d17f9805b5 Mon Sep 17 00:00:00 2001 From: Briksisn Date: Tue, 30 Jun 2015 16:45:55 +0100 Subject: [PATCH] [IMP] hr: automatic fields population When creating new Employee and linking to the existed user, this fix will populate not only email address field, but also full name and avatar image. Closes #7397 --- addons/hr/hr.py | 10 +++++++--- addons/hr/hr_view.xml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 62ce66995ec..7e8860477c8 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -247,10 +247,14 @@ class hr_employee(osv.osv): return {'value': value} def onchange_user(self, cr, uid, ids, user_id, context=None): - work_email = False if user_id: - work_email = self.pool.get('res.users').browse(cr, uid, user_id, context=context).email - return {'value': {'work_email': work_email}} + user = self.pool['res.users'].browse(cr, uid, user_id, context=context) + values = { + 'name': user.name, + 'work_email': user.email, + 'image': user.image, + } + return {'value': values} def action_follow(self, cr, uid, ids, context=None): """ Wrapper because message_subscribe_users take a user_ids=None diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index 0ec9f1ae48a..17ff2ba3ffa 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -24,7 +24,7 @@
- +