From 4d2d40c45285d3d5fbe1c7ce3225f4aaf45483e1 Mon Sep 17 00:00:00 2001 From: steveferry Date: Mon, 1 Jun 2015 16:13:07 +0200 Subject: [PATCH] Keep partner's lastname if it has one --- partner_firstname/res_user.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/partner_firstname/res_user.py b/partner_firstname/res_user.py index 447d34661..100381dfc 100644 --- a/partner_firstname/res_user.py +++ b/partner_firstname/res_user.py @@ -35,8 +35,14 @@ class ResUsers(orm.Model): installed """ vals2 = vals.copy() + + res_partner = self.pool.get('res.partner') + partner = res_partner.browse(cr, user, vals2['partner_id'], context) + if 'name' in vals: vals2['lastname'] = vals2['name'] + elif partner.lastname: + vals2['lastname'] = partner.lastname elif 'login' in vals and 'lastname' not in vals: vals2['lastname'] = vals2['login'] return super(ResUsers, self).create(cr, user, vals2, context=context)