Browse Source

Fix pep8

pull/487/head
Sandy Carter 11 years ago
committed by Enric Tobella
parent
commit
ebf9a92c79
  1. 21
      partner_firstname/__init__.py
  2. 4
      partner_firstname/partner.py
  3. 4
      partner_firstname/res_user.py
  4. 4
      partner_firstname/tests/__init__.py
  5. 28
      partner_firstname/tests/test_partner_firstname.py

21
partner_firstname/__init__.py

@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import partner
from . import res_user

4
partner_firstname/partner.py

@ -83,7 +83,9 @@ class ResPartner(Model):
default = default or {}
if not default.get('lastname'):
default = default.copy()
default['lastname'] = _('%s (copy)') % self.read(cr, uid, [_id], ['lastname'], context=context)[0]['lastname']
default['lastname'] = (
_('%s (copy)') % self.read(cr, uid, [_id], ['lastname'], context=context)[0]['lastname']
)
if default.get('name'):
del(default['name'])
return super(ResPartner, self).copy_data(cr, uid, _id, default, context=context)

4
partner_firstname/res_user.py

@ -32,7 +32,9 @@ class ResUsers(orm.Model):
default = default or {}
if not default.get('lastname'):
default = default.copy()
default['lastname'] = _('%s (copy)') % self.read(cr, uid, [_id], ['lastname'], context=context)[0]['lastname']
default['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)

4
partner_firstname/tests/__init__.py

@ -32,6 +32,4 @@ import test_partner_firstname
checks = [
test_partner_firstname
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
]

28
partner_firstname/tests/test_partner_firstname.py

@ -52,9 +52,17 @@ class test_partner_firstname(common.TransactionCase):
res_id = self.partner_model.create(cr, uid, self.fields_partner, context=context)
res_id = self.partner_model.copy(cr, uid, res_id, default={}, context=context)
vals = self.partner_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], _('%s (copy)') % 'lastname' + " firstname", 'Copy of the partner failed with wrong name')
self.assertEqual(vals['lastname'], _('%s (copy)') % 'lastname', 'Copy of the partner failed with wrong lastname')
self.assertEqual(
vals['name'],
_('%s (copy)') % 'lastname' + " firstname",
'Copy of the partner failed with wrong name'
)
self.assertEqual(
vals['lastname'],
_('%s (copy)') % 'lastname',
'Copy of the partner failed with wrong lastname'
)
self.assertEqual(vals['firstname'], 'firstname', 'Copy of the partner failed with wrong firstname')
def test_copy_user(self):
@ -63,12 +71,16 @@ class test_partner_firstname(common.TransactionCase):
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.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname': 'firstname'}, context=context)
# copy the user and compare result
res_id = self.user_model.copy(cr, uid, res_id, default={}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], _('%s (copy)') % 'lastname' + ' firstname', 'Copy of the user failed with wrong name')
self.assertEqual(
vals['name'],
_('%s (copy)') % 'lastname' + ' firstname',
'Copy of the user failed with wrong name'
)
self.assertEqual(vals['lastname'], _('%s (copy)') % 'lastname', 'Copy of the user failed with wrong lastname')
self.assertEqual(vals['firstname'], 'firstname', 'Copy of the user failed with wrong firstname')
@ -78,7 +90,7 @@ class test_partner_firstname(common.TransactionCase):
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.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname': 'firstname'}, context=context)
self.user_model.write(cr, uid, res_id, {'name': 'change firstname'}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
@ -92,12 +104,10 @@ class test_partner_firstname(common.TransactionCase):
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.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')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Loading…
Cancel
Save