diff options
| author | Kevin Baptiste <kba@odoo.com> | 2019-05-16 13:30:01 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2019-06-28 06:59:32 +0000 |
| commit | f17655dd773096f2d37ece392dfe980ae4795819 (patch) | |
| tree | 13045498b08d8975d3155c72c34bd347e2280676 /addons/hr_contract/tests | |
| parent | 5548029fb73c420a308772e9c54b8119775105b7 (diff) | |
[IMP] hr_contract: Replace some contract states by kanban status
Purpose
=======
Having some usability check to be sure to make the pay
for everyone, and don't loose contracts.
We would like to remove incoming and to renew columns in
hr.contract and replace them by a kanban state. In employee, we would
like to add warning on the kanban to warn the hr responsible there
is no contract or a contract is about to expire
Specification
=============
hr.contract kanban:
- add a kanabn state
- it becomes red automatically when the contract is in running and expire in 7 days
- add aquick search in filter to filter on expered soon
- the kanban state can be changed manaually (in case of there is several rh)
- sort by contract end date set first (more close of today first)
Employee kanban
- add an red icon if there is no contract in Runnig status OR there is a
kanban state red in their contract (whatever the status).
- add a quick seaach on employee with warning
- State pending + green = incoming
- State confirmed + red = about to expire / to renew
closes odoo/odoo#33489
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/hr_contract/tests')
| -rw-r--r-- | addons/hr_contract/tests/test_auto_status.py | 19 | ||||
| -rw-r--r-- | addons/hr_contract/tests/test_contract.py | 29 |
2 files changed, 29 insertions, 19 deletions
diff --git a/addons/hr_contract/tests/test_auto_status.py b/addons/hr_contract/tests/test_auto_status.py index c342d05dd0f..fcff8621bb9 100644 --- a/addons/hr_contract/tests/test_auto_status.py +++ b/addons/hr_contract/tests/test_auto_status.py @@ -12,6 +12,9 @@ class TestHrContracts(TestContractBase): self.contracts = self.env['hr.contract'].with_context(tracking_disable=True) self.test_contract = dict(name='Test', wage=1, employee_id=self.employee.id, state='open') + def test_employee_contractwarning(self): + self.assertEquals(self.employee.contract_warning, True) + def apply_cron(self): self.env.ref('hr_contract.ir_cron_data_contract_update_state').method_direct_trigger() @@ -20,16 +23,20 @@ class TestHrContracts(TestContractBase): self.contract = self.contracts.create(self.test_contract) self.apply_cron() self.assertEquals(self.contract.state, 'open') + self.assertEquals(self.contract.kanban_state, 'normal') + self.assertEquals(self.employee.contract_warning, False) self.test_contract.update(dict(date_end=datetime.now() + relativedelta(days=5))) self.contract.write(self.test_contract) self.apply_cron() - self.assertEquals(self.contract.state, 'pending') + self.assertEquals(self.contract.state, 'open') + self.assertEquals(self.contract.kanban_state, 'blocked') self.test_contract.update({ 'date_start': datetime.now() + relativedelta(days=-50), 'date_end': datetime.now() + relativedelta(days=-1), - 'state': 'pending', + 'state': 'open', + 'kanban_state': 'blocked', }) self.contract.write(self.test_contract) self.apply_cron() @@ -40,19 +47,21 @@ class TestHrContracts(TestContractBase): self.test_contract.update(dict(date_end=False)) self.contract = self.contracts.create(self.test_contract) self.apply_cron() - self.assertEquals(self.contract.state, 'pending') + self.assertEquals(self.contract.state, 'open') + self.assertEquals(self.contract.kanban_state, 'blocked') self.employee.visa_expire = date.today() + relativedelta(days=-5) self.test_contract.update({ 'date_start': datetime.now() + relativedelta(days=-50), - 'state': 'pending', + 'state': 'open', + 'kanban_state': 'blocked', }) self.contract.write(self.test_contract) self.apply_cron() self.assertEquals(self.contract.state, 'close') def test_contract_start_date(self): - self.test_contract.update(dict(date_start=datetime.now(), state='incoming')) + self.test_contract.update(dict(date_start=datetime.now(), state='draft', kanban_state='done')) self.contract = self.contracts.create(self.test_contract) self.apply_cron() self.assertEquals(self.contract.state, 'open') diff --git a/addons/hr_contract/tests/test_contract.py b/addons/hr_contract/tests/test_contract.py index ca05600929c..3d339c4c101 100644 --- a/addons/hr_contract/tests/test_contract.py +++ b/addons/hr_contract/tests/test_contract.py @@ -12,11 +12,12 @@ class TestHrContracts(TestContractBase): super(TestHrContracts, self).setUp() self.contracts = self.env['hr.contract'].with_context(tracking_disable=True) - def create_contract(self, state, start, end=None): + def create_contract(self, state, kanban_state, start, end=None): return self.env['hr.contract'].create({ 'name': 'Contract', 'employee_id': self.employee.id, 'state': state, + 'kanban_state': kanban_state, 'wage': 1, 'date_start': start, 'date_end': end, @@ -25,65 +26,65 @@ class TestHrContracts(TestContractBase): def test_incoming_overlapping_contract(self): start = datetime.strptime('2015-11-01', '%Y-%m-%d').date() end = datetime.strptime('2015-11-30', '%Y-%m-%d').date() - self.create_contract('open', start, end) + self.create_contract('open', 'normal', start, end) # Incoming contract with self.assertRaises(ValidationError, msg="It should not create two contract in state open or incoming"): start = datetime.strptime('2015-11-15', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('incoming', start, end) + self.create_contract('draft', 'done', start, end) def test_pending_overlapping_contract(self): start = datetime.strptime('2015-11-01', '%Y-%m-%d').date() end = datetime.strptime('2015-11-30', '%Y-%m-%d').date() - self.create_contract('open', start, end) + self.create_contract('open', 'normal', start, end) # Pending contract with self.assertRaises(ValidationError, msg="It should not create two contract in state open or pending"): start = datetime.strptime('2015-11-15', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('pending', start, end) + self.create_contract('open', 'blocked', start, end) # Draft contract -> should not raise start = datetime.strptime('2015-11-15', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('draft', start, end) + self.create_contract('draft', 'normal', start, end) def test_draft_overlapping_contract(self): start = datetime.strptime('2015-11-01', '%Y-%m-%d').date() end = datetime.strptime('2015-11-30', '%Y-%m-%d').date() - self.create_contract('open', start, end) + self.create_contract('open', 'normal', start, end) # Draft contract -> should not raise even if overlapping start = datetime.strptime('2015-11-15', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('draft', start, end) + self.create_contract('draft', 'normal', start, end) def test_overlapping_contract_no_end(self): # No end date - self.create_contract('open', datetime.strptime('2015-11-01', '%Y-%m-%d').date()) + self.create_contract('open', 'normal', datetime.strptime('2015-11-01', '%Y-%m-%d').date()) with self.assertRaises(ValidationError): start = datetime.strptime('2015-11-15', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('incoming', start, end) + self.create_contract('draft', 'done', start, end) def test_overlapping_contract_no_end2(self): start = datetime.strptime('2015-11-01', '%Y-%m-%d').date() end = datetime.strptime('2015-12-30', '%Y-%m-%d').date() - self.create_contract('open', start, end) + self.create_contract('open', 'normal', start, end) with self.assertRaises(ValidationError): # No end - self.create_contract('incoming', datetime.strptime('2015-01-01', '%Y-%m-%d').date()) + self.create_contract('draft', 'done', datetime.strptime('2015-01-01', '%Y-%m-%d').date()) def test_set_employee_contract_create(self): - contract = self.create_contract('open', date(2018, 1, 1), date(2018, 1, 2)) + contract = self.create_contract('open', 'normal', date(2018, 1, 1), date(2018, 1, 2)) self.assertEqual(self.employee.contract_id, contract) def test_set_employee_contract_write(self): - contract = self.create_contract('draft', date(2018, 1, 1), date(2018, 1, 2)) + contract = self.create_contract('draft', 'normal', date(2018, 1, 1), date(2018, 1, 2)) contract.state = 'open' self.assertEqual(self.employee.contract_id, contract) |
