Skip to content

Commit

Permalink
[MIG] hr (continuation)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Jul 6, 2021
1 parent 4d3a63e commit d186870
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|google_spreadsheet | |
+--------------------------------------------+-------------------------------------------------+
|hr | |
|hr | Done |
+--------------------------------------------+-------------------------------------------------+
|hr_attendance | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
8 changes: 4 additions & 4 deletions openupgrade_scripts/scripts/hr/14.0.1.1/noupdate_changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<field name="address_home_id" ref="res_partner_admin_private_address"/>
</record>
<record id="hr_dept_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="hr_employee_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="hr_employee_public_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="hr_job_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
</odoo>
28 changes: 24 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 @@ -2,20 +2,40 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


def fill_hr_employee_company_id(env):
openupgrade.logged_query(
env.cr, """
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
WHERE ru.id = hr.create_uid AND hr.company_id is NULL
""",
)


def update_new_private_admin_partner(env):
public_partner = env.ref("hr.res_partner_admin_private_address")
private_partner = env.ref("hr.employee_admin").address_home_id
private_partner.update(
{
"name": public_partner.name,
"company_id": public_partner.company_id,
"email": public_partner.email,
"image_1920": public_partner.image_1920,
}
)


@openupgrade.migrate()
def migrate(env, version):
fill_hr_employee_company_id(env)
# Load noupdate changes
update_new_private_admin_partner(env)
openupgrade.load_data(env.cr, "hr", "14.0.1.1/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr, "hr", ["mail_template_data_unknown_employee_email_address"]
)
openupgrade.delete_records_safely_by_xml_id(
env.cr, ["hr.mail_template_data_unknown_employee_email_address"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
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 / company_id (many2one) : now required, req_default: function
# DONE: Post-migration: Filled with Create user 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
hr / res.users / barcode (char) : module is now 'base' ('hr')
# NOTHING TO DO

---XML records in module 'hr'---
NEW ir.actions.act_window: hr.hr_department_kanban_action
NEW ir.actions.act_window: hr.hr_department_tree_action
Expand All @@ -20,7 +25,10 @@ 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

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

NEW res.partner: hr.res_partner_admin_private_address (noupdate)
hr.employee: hr.employee_admin (noupdate)
# DONE: post-migration: noupdate changed to "res_partner_admin_private_address"
# DONE: post-migration: update this partner with actual admin data

0 comments on commit d186870

Please sign in to comment.