Browse Source

[FIX] cannot create user due to required name.

pull/663/head
Ronald Portier (Therp BV) 9 years ago
committed by Jairo Llopis
parent
commit
87d3dbf41f
  1. 11
      partner_firstname/partner.py
  2. 12
      partner_firstname/res_user.py

11
partner_firstname/partner.py

@ -115,15 +115,12 @@ class ResPartner(orm.Model):
even if we use fnct_inv: otherwise we can't create entry because
lastname is mandatory and module will not install if there is demo data
"""
to_use = vals
if 'name' in vals:
corr_vals = vals.copy()
if vals.get('name'):
corr_vals['lastname'] = corr_vals['name']
corr_vals = vals.copy()
if corr_vals.get('name'):
corr_vals['lastname'] = corr_vals['name']
del(corr_vals['name'])
to_use = corr_vals
return super(ResPartner, self).create(
cursor, uid, to_use, context=context)
cursor, uid, corr_vals, context=context)
_columns = {'name': fields.function(_compute_name_custom, string="Name",
type="char", store=True,

12
partner_firstname/res_user.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
"""Extend res.users to be compatible with split name in res.partner."""
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
@ -17,14 +18,19 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm
from openerp import api, models
from openerp.tools.translate import _
class ResUsers(orm.Model):
class ResUsers(models.Model):
"""Extend res.users to be compatible with split name in res.partner."""
_inherit = 'res.users'
@api.onchange('firstname', 'lastname')
def change_name(self):
names = [name for name in [self.firstname, self.lastname] if name]
self.name = ' '.join(names)
def copy_data(self, cr, uid, _id, default=None, context=None):
"""
Avoid to replicate the firstname into the name when duplicating a user

Loading…
Cancel
Save