|
@ -29,11 +29,14 @@ |
|
|
############################################################################## |
|
|
############################################################################## |
|
|
import openerp.tests.common as common |
|
|
import openerp.tests.common as common |
|
|
|
|
|
|
|
|
|
|
|
from openerp.tools.translate import _ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class test_partner_firstname(common.TransactionCase): |
|
|
class test_partner_firstname(common.TransactionCase): |
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
def setUp(self): |
|
|
super(test_partner_firstname, self).setUp() |
|
|
super(test_partner_firstname, self).setUp() |
|
|
|
|
|
|
|
|
self.registry('ir.model').clear_caches() |
|
|
self.registry('ir.model').clear_caches() |
|
|
self.registry('ir.model.data').clear_caches() |
|
|
self.registry('ir.model.data').clear_caches() |
|
|
|
|
|
|
|
@ -42,53 +45,59 @@ class test_partner_firstname(common.TransactionCase): |
|
|
self.fields_partner = {'lastname': 'lastname', 'firstname': 'firstname'} |
|
|
self.fields_partner = {'lastname': 'lastname', 'firstname': 'firstname'} |
|
|
self.fields_user = {'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'} |
|
|
self.fields_user = {'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'} |
|
|
|
|
|
|
|
|
|
|
|
self.context = self.user_model.context_get(self.cr, self.uid) |
|
|
|
|
|
|
|
|
def test_copy_partner(self): |
|
|
def test_copy_partner(self): |
|
|
cr, uid = self.cr, self.uid |
|
|
|
|
|
res_id = self.partner_model.create(cr, uid, self.fields_partner, context={}) |
|
|
|
|
|
res_id = self.partner_model.copy(cr, uid, res_id, default={}, context={}) |
|
|
|
|
|
vals = self.partner_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0] |
|
|
|
|
|
self.assertEqual(vals['name'] == "lastname (copy) firstname" and |
|
|
|
|
|
vals['lastname'] == 'lastname (copy)' and |
|
|
|
|
|
vals['firstname'] == 'firstname', True, 'Copy of the partner failed with wrong values') |
|
|
|
|
|
|
|
|
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] |
|
|
|
|
|
|
|
|
|
|
|
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): |
|
|
def test_copy_user(self): |
|
|
cr, uid = self.cr, self.uid |
|
|
|
|
|
|
|
|
cr, uid, context = self.cr, self.uid, self.context |
|
|
# create a user |
|
|
# create a user |
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context={}) |
|
|
|
|
|
|
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context=context) |
|
|
# get the related partner id and add it a firstname |
|
|
# get the related partner id and add it a firstname |
|
|
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0] |
|
|
|
|
|
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, 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 |
|
|
# copy the user and compare result |
|
|
res_id = self.user_model.copy(cr, uid, res_id, default={}, context={}) |
|
|
|
|
|
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0] |
|
|
|
|
|
self.assertEqual(vals['name'] == "lastname (copy) firstname" and |
|
|
|
|
|
vals['lastname'] == 'lastname (copy)' and |
|
|
|
|
|
vals['firstname'] == 'firstname', True, 'Copy of the user failed with wrong values') |
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
def test_update_user_lastname(self): |
|
|
def test_update_user_lastname(self): |
|
|
cr, uid = self.cr, self.uid |
|
|
|
|
|
|
|
|
cr, uid, context = self.cr, self.uid, self.context |
|
|
# create a user |
|
|
# create a user |
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context={}) |
|
|
|
|
|
|
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context=context) |
|
|
# get the related partner id and add it a firstname |
|
|
# get the related partner id and add it a firstname |
|
|
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0] |
|
|
|
|
|
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context={}) |
|
|
|
|
|
self.user_model.write(cr, uid, res_id, {'name': 'change firstname'}, context={}) |
|
|
|
|
|
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0] |
|
|
|
|
|
self.assertEqual(vals['name'] == "change firstname" and |
|
|
|
|
|
vals['lastname'] == 'change' and |
|
|
|
|
|
vals['firstname'] == 'firstname', True, 'Update of the user lastname failed with wrong values') |
|
|
|
|
|
|
|
|
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['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): |
|
|
def test_update_user_firstname(self): |
|
|
cr, uid = self.cr, self.uid |
|
|
|
|
|
|
|
|
cr, uid, context = self.cr, self.uid, self.context |
|
|
# create a user |
|
|
# create a user |
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context={}) |
|
|
|
|
|
|
|
|
res_id = self.user_model.create(cr, uid, self.fields_user, context=context) |
|
|
# get the related partner id and add it a firstname |
|
|
# get the related partner id and add it a firstname |
|
|
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0] |
|
|
|
|
|
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context={}) |
|
|
|
|
|
self.user_model.write(cr, uid, res_id, {'name': 'lastname other'}, context={}) |
|
|
|
|
|
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0] |
|
|
|
|
|
self.assertEqual(vals['name'] == "lastname other" and |
|
|
|
|
|
vals['lastname'] == 'lastname other' and |
|
|
|
|
|
vals['firstname'] == False, True, 'Update of the user firstname failed with wrong values') |
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |