diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index b4be005a5..85dd9b53c 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -2,6 +2,7 @@ ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA +# Copyright (C) 2014 Agile Business Group () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/partner_firstname/tests/test_partner_firstname.py b/partner_firstname/tests/test_partner_firstname.py index 0e7c81afe..a4bac1ee0 100644 --- a/partner_firstname/tests/test_partner_firstname.py +++ b/partner_firstname/tests/test_partner_firstname.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Authors: Nemry Jonathan # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) @@ -26,7 +26,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -############################################################################## +# import openerp.tests.common as common from openerp.tools.translate import _ @@ -42,16 +42,21 @@ class test_partner_firstname(common.TransactionCase): self.user_model = self.registry("res.users") self.partner_model = self.registry("res.partner") - self.fields_partner = {'lastname': 'lastname', 'firstname': 'firstname'} - self.fields_user = {'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'} + self.fields_partner = { + 'lastname': 'lastname', 'firstname': 'firstname'} + self.fields_user = { + 'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'} self.context = self.user_model.context_get(self.cr, self.uid) def test_copy_partner(self): cr, uid, context = self.cr, self.uid, self.context - 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] + 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'], @@ -63,38 +68,56 @@ class test_partner_firstname(common.TransactionCase): _('%s (copy)') % 'lastname', 'Copy of the partner failed with wrong lastname' ) - self.assertEqual(vals['firstname'], 'firstname', 'Copy of the partner failed with wrong firstname') + self.assertEqual(vals['firstname'], 'firstname', + 'Copy of the partner failed with wrong firstname') def test_copy_user(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) + 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) # 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] + 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['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') + 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') def test_update_user_lastname(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': 'change firstname'}, 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': 'change firstname'}, context=context) + 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['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')