- In order to test process of Phases, - I create a record to schedule the phase of project. - !record {model: project.compute.phases, id: project_compute_phases01}: target_project: 'one' project_id: project.project_project_1 - I schedule the phases. - !python {model: project.compute.phases}: | self.check_selection(cr, uid, [ref("project_compute_phases01")]) - I check the starting date and ending date on the phases after scheduling. - !python {model: project.project}: | project = self.browse(cr, uid, ref("project.project_project_1"), context=context) def _convert(date): import time return time.strptime(date, '%Y-%m-%d %H:%M:%S') def _check(phase, _convert, _check): #TOFIX: why need to pass function ? for next_phase in phase.next_phase_ids: assert _convert(next_phase.date_start) >= _convert(phase.date_end), "Phase does not start in proper date." _check(next_phase, _convert, _check) return True for phase in project.phase_ids: assert phase.date_start, "Start date should be computed." assert phase.date_end, "End date should be computed." if not phase.previous_phase_ids and phase.constraint_date_start: assert _convert(phase.date_start) >= _convert(phase.constraint_date_start), "Phase does not start in proper date." _check(phase, _convert, _check) - I open phase. - !python {model: project.phase}: | self.set_open(cr, uid, [ref("project_phase_1")]) - I check state of phase after opened. - !assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in open state}: - state == "open" - I put phase in pending state. - !python {model: project.phase}: | self.set_pending(cr, uid, [ref("project_phase_1")]) - I check state of phase after put in pending. - !assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in pending state}: - state == "pending" - I make Phase in cancel state. - !python {model: project.phase}: | self.set_cancel(cr, uid, [ref("project_phase_1")]) - I check state of phase after cancelled. - !assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in cancel state}: - state == "cancelled" - I put again in draft phase. - !python {model: project.phase}: | self.set_draft(cr, uid, [ref("project_phase_1")]) - I close phase. - !python {model: project.phase}: | self.set_done(cr, uid, [ref("project_phase_1")]) - I check state of phase after closed. - !assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in done state}: - state == "done"