Skip to content

Commit

Permalink
[FIX+IMP] hr: Finish migration scripts
Browse files Browse the repository at this point in the history
- Add more comments to the analysis work file
- Refine company_id assignation using department's company first
- Don't load noupdate records without changes

TT29982
  • Loading branch information
pedrobaeza committed Dec 11, 2021
1 parent 9e4b4a6 commit 5a695d5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
24 changes: 12 additions & 12 deletions openupgrade_scripts/scripts/hr/14.0.1.1/noupdate_changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<record id="employee_admin" model="hr.employee">
<field name="address_home_id" ref="res_partner_admin_private_address"/>
</record>
<record id="hr_dept_comp_rule" model="ir.rule">
<!-- <field name="global"/>-->
</record>
<record id="hr_employee_comp_rule" model="ir.rule">
<!-- <field name="global"/>-->
</record>
<record id="hr_employee_public_comp_rule" model="ir.rule">
<!-- <field name="global"/>-->
</record>
<record id="hr_job_comp_rule" model="ir.rule">
<!-- <field name="global"/>-->
</record>
<!-- <record id="hr_dept_comp_rule" model="ir.rule">
<field name="global"/>
</record> -->
<!-- <record id="hr_employee_comp_rule" model="ir.rule">
<field name="global"/>
</record> -->
<!-- <record id="hr_employee_public_comp_rule" model="ir.rule">
<field name="global"/>
</record> -->
<!-- <record id="hr_job_comp_rule" model="ir.rule">
<field name="global"/>
</record> -->
</odoo>
10 changes: 6 additions & 4 deletions openupgrade_scripts/scripts/hr/14.0.1.1/post-migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ def fill_hr_employee_company_id(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE hr_employee hr
SET company_id = ru.company_id
FROM res_users ru
WHERE ru.id = hr.create_uid AND hr.company_id is NULL
UPDATE hr_employee he
SET company_id = COALESCE(hd.company_id, ru.company_id)
FROM hr_employee he2
JOIN res_users ru ON ru.id = COALESCE(he2.create_uid, 1)
LEFT JOIN hr_department hd ON hd.id = he2.department_id
WHERE he.id = he2.id AND he.company_id is NULL
""",
)

Expand Down
20 changes: 12 additions & 8 deletions openupgrade_scripts/scripts/hr/14.0.1.1/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
---Models in module 'hr'---
---Fields in module 'hr'---
hr / hr.employee / address_id (many2one) : now a function
hr / hr.employee / certificate (selection) : selection_keys is now '['bachelor', 'doctor', 'graduate', 'master', 'other']' ('['bachelor', 'master', 'other']')
hr / hr.employee / coach_id (many2one) : now a function
# NOTHING TO DO
hr / hr.employee / parent_id (many2one) : now a function
hr / hr.employee / job_title (char) : now a function
hr / hr.employee / work_phone (char) : now a function
hr / hr.plan.activity.type / summary (char) : now a function
# NOTHING TO DO: Converted to computed writable fields and the depends are not being changed (nor the dependency chain)

hr / hr.employee / certificate (selection) : selection_keys is now '['bachelor', 'doctor', 'graduate', 'master', 'other']' ('['bachelor', 'master', 'other']')
# NOTHING TO DO: Only extra values

hr / hr.employee / company_id (many2one) : now required, req_default: function
# DONE: Post-migration: Filled with Create user company_id
# DONE: post-migration: Filled with the most proper data those without company_id

hr / hr.employee / departure_date (date) : NEW
hr / hr.employee / job_title (char) : now a function
hr / hr.employee / parent_id (many2one) : now a function
hr / hr.employee / work_phone (char) : now a function
hr / hr.plan.activity.type / summary (char) : now a function
# NOTHING TO DO: New info field

hr / res.users / barcode (char) : module is now 'base' ('hr')
# NOTHING TO DO

Expand All @@ -25,7 +29,7 @@ NEW ir.model.access: hr.access_hr_plan_wizard
DEL ir.model.access: hr.access_ir_property_hr_user
NEW ir.ui.menu: hr.menu_hr_department_kanban
NEW ir.ui.view: hr.qunit_suite
# NOTHING TO DO
# NOTHING TO DO: noupdate=0 records

DEL mail.template: hr.mail_template_data_unknown_employee_email_address (noupdate)
# DONE: post-migration: deleted xmlid safely (and its translations)
Expand Down

0 comments on commit 5a695d5

Please sign in to comment.