Repository navigation
[OU-FIX] hr: rename contract types and map the employee type selection - #9
Merged
Merged
Conversation
Co-authored-by: André de Kock <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Loading hr 20.0 raises:
while parsing
hr/data/hr_employee_type_data.xml:4. The xmlidshr.contract_type_*still point athr.contract.type.Root cause
Odoo 20 replaces
hr.contract.typewithhr.employee.typeand reuses the same xmlids.hr.job.contract_type_idandhr.version.contract_type_idbecomeemployee_type_id. The required selectionhr.version.employee_type(employee,worker,student,trainee,contractor,freelance) is removed. Without a pre-migration rename, the data file tries to load anhr.employee.typerecord through an xmlid that still nameshr.contract.type.Change
Written from
hr/20.0.1.1/upgrade_analysis.txt, not only the rename.upgrade_analysis_work.txtmarks each line DONE or NOTHING TO DO.Pre-migration:
rename_models/rename_tables:hr.contract.type→hr.employee.type,hr_contract_type→hr_employee_type.ir_model_data.modelfor those rows is updated before the data file loads, so the xmlids update the renamed records instead of raising a different-model error.ir.actions.act_window.res_model,ir.ui.view.modeland view arches are rewritten the same way.rename_fields:contract_type_id→employee_type_idonhr.jobandhr.version.employee_type,departure_reason_id,departure_descriptionanddeparture_dateare copied withopenupgrade.copy_columns.hr.version.tzis added and filled fromhr.employee.tz(NULL becomesUTC) because the version field is now stored and required. NULLresource_calendar_idis filled from the company calendar, then any calendar.hr.job.company_idNULL is filled from the department, then the first company. Both are now required.additional_noteandcontract_template_idare copied from the employee's current version ontohr.employee(they stop being related).hr.job.user_id(res.users) is copied to the newrecruiter_id(hr.employee), preferring an employee of the job's company.sex = 'other'is cleared. The key is gone and the field is not required.Post-migration:
employee_type_idonly when that column is NULL or still points at a standard type that 20.0 dropped (contract_type_full_time,part_time,permanent,statutory,temporary). A version that already points at a type 20.0 still ships (Apprenticeship, Interim, Intern, Student, …) or at a custom type keeps that type. The selection defaults toemployeeand must not wipe a more specific contract type.hr/data/hr_employee_type_data.xml(there is no worker, contractor or freelance type):employee→hr.contract_type_employeeworker→hr.contract_type_employee(20.0 droppedhr.structure_type_worker; worker was the payroll split, not a separate employee type)student→hr.contract_type_studenttrainee→hr.contract_type_interncontractorandfreelance→hr.contract_type_interim(Interim is the non-permanent engagement that is not student, intern, seasonal, apprenticeship or thesis)hr.employee.departureper version that had a reason, date or description and an employee, and setshr.version.departure_id. A missing reason uses the firsthr.departure.reasonbecause the new field is required.dismissal_dateis the departure date (or today).action_dateis the next day. Contract templates (employee_idNULL) are skipped.20.0.1.1/noupdate_changes.xml(sequences on the renamed types, Belgium Pay structure name, disabled bank rules).Merged modules (
hr_homeworking,hr_org_chart,hr_hourly_cost) are already inapriori.merged_modulesand are handled by the base migration. Removed columns are not dropped by OpenUpgrade, sossnid,study_schoolandprivate_car_platestay in the database with no successor field.Verification
Field list checked against Odoo 19
hr.version/hr.employee/hr.joband Odoo 20hr.employee.type,hr.version,hr.employee.departureandhr_employee_type_data.xml. The six selection keys are all mapped (asserted by reading the dict).ruffandpy_compileare clean. No database upgrade was run.No OCA pull request migrates hr 20.0. The analysis in OCA OCA#6068 lists the model change and does not ship scripts.
Upstream
Generic. Submit to OCA
20.0on top of OCA#6068. Not applicable to 18.0 or 19.0.Limitations
contractorandfreelanceboth become Interim. The legacy column is the only remaining distinction.workerbecomes Employee. Belgian payroll structure types that 20.0 deletes from the data file are left in place (they are noupdate).full_time,part_time,permanent,statutory,temporary) are kept ashr.employee.typerows when something still points at them, and replaced by the selection mapping when a version points at them and the selection says something more specific. Custom contract types are never overwritten.hr.employee.departure's date constraints (contract start versus departure date) do not abort the upgrade. A departure that would have been invalid in the UI is still created.birthday_month,first_contract_dateandphone_sanitizedare left for the ORM to compute. They read onlyhr.employee, which is loaded with this module.