Skip to content

Commit

Permalink
[REF] hr_employee_firstname: Split names at module install to get the…
Browse files Browse the repository at this point in the history
… value not the key of dict (OCA#215)

* Update split names at module install to get the value not the key of the dict.
* Add test for checking right values in firstname, lastname after install
  • Loading branch information
feketemihai authored and andreagidaltig committed Nov 16, 2023
1 parent 1172d1f commit e57a505
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hr_employee_firstname/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def _update_employee_names(self):
('firstname', '=', ' '), ('lastname', '=', ' ')])

for ee in employees:
lastname, firstname = self.split_name(ee.name)
split_name = self.split_name(ee.name)
ee.write({
'firstname': firstname,
'lastname': lastname,
'firstname': split_name['firstname'],
'lastname': split_name['lastname'],
})

@api.model
Expand Down
9 changes: 9 additions & 0 deletions hr_employee_firstname/tests/test_hr_employee_firstname.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
##############################################################################

import openerp.tests
from openerp.tests.common import TransactionCase


Expand Down Expand Up @@ -109,3 +110,11 @@ def test_change_firstname_and_lastname(self):
self.employee1_id.refresh()

self.assertEqual(self.employee1_id.name, 'Carnaud Jean-Pierre')

@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
def test_update_name_post_install(self):
self.empl_demo = self.env.ref('hr.employee_fp')

self.assertEqual(self.empl_demo.firstname, 'Parker')
self.assertEqual(self.empl_demo.lastname, 'Pieter')

0 comments on commit e57a505

Please sign in to comment.