Browse Source

[FIX] partner_firstname - some PEP8

pull/14/head
Lorenzo Battistini 10 years ago
parent
commit
8dc056bd2a
  1. 6
      partner_firstname/__openerp__.py
  2. 7
      partner_firstname/res_user.py
  3. 37
      partner_firstname/tests/test_partner_firstname.py

6
partner_firstname/__openerp__.py

@ -24,8 +24,10 @@
This module splits first name and last name for non company partners
====================================================================
The field 'name' becomes a stored function field concatenating lastname and firstname
Note: in version 7.0, installing this module invalidates a yaml test in the 'edi' module
The field 'name' becomes a stored function field concatenating lastname and
firstname
Note: in version 7.0, installing this module invalidates a yaml test in the
'edi' module
Contributors
============

7
partner_firstname/res_user.py

@ -33,8 +33,11 @@ class ResUsers(orm.Model):
if not default.get('lastname'):
default = default.copy()
default['lastname'] = (
_('%s (copy)') % self.read(cr, uid, [_id], ['lastname'], context=context)[0]['lastname']
_('%s (copy)') % self.read(
cr, uid, [_id], ['lastname'], context=context
)[0]['lastname']
)
if default.get('name'):
del(default['name'])
return super(ResUsers, self).copy_data(cr, uid, _id, default, context=context)
return super(ResUsers, self).copy_data(
cr, uid, _id, default, context=context)

37
partner_firstname/tests/test_partner_firstname.py

@ -95,19 +95,36 @@ class test_partner_firstname(common.TransactionCase):
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], 'change firstname', 'Update of the user lastname failed with wrong name')
self.assertEqual(vals['lastname'], 'change', 'Update of the user lastname failed with wrong lastname')
self.assertEqual(vals['firstname'], 'firstname', 'Update of the user lastname failed with wrong firstname')
self.assertEqual(
vals['lastname'], 'change',
'Update of the user lastname failed with wrong lastname')
self.assertEqual(
vals['firstname'], 'firstname',
'Update of the user lastname failed with wrong firstname')
def test_update_user_firstname(self):
cr, uid, context = self.cr, self.uid, self.context
# create a user
res_id = self.user_model.create(cr, uid, self.fields_user, context=context)
res_id = self.user_model.create(
cr, uid, self.fields_user, context=context)
# get the related partner id and add it a firstname
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context=context)[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname': 'firstname'}, context=context)
self.user_model.write(cr, uid, res_id, {'name': 'lastname other'}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
flds = self.user_model.read(
cr, uid, [res_id], ['partner_id'], context=context)[0]
self.partner_model.write(
cr, uid, flds['partner_id'][0], {'firstname': 'firstname'},
context=context)
self.user_model.write(
cr, uid, res_id, {'name': 'lastname other'}, context=context)
vals = self.user_model.read(
cr, uid, [res_id], ['name', 'lastname', 'firstname'],
context=context)[0]
self.assertEqual(vals['name'], 'lastname other', 'Update of the user firstname failed with wrong name')
self.assertEqual(vals['lastname'], 'lastname other', 'Update of the user firstname failed with wrong lastname')
self.assertFalse(vals['firstname'], 'Update of the user firstname failed with wrong firstname')
self.assertEqual(
vals['name'], 'lastname other',
'Update of the user firstname failed with wrong name')
self.assertEqual(
vals['lastname'], 'lastname other',
'Update of the user firstname failed with wrong lastname')
self.assertFalse(
vals['firstname'],
'Update of the user firstname failed with wrong firstname')
Loading…
Cancel
Save