diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst index 6fba859261d8..e1e701f2005a 100644 --- a/docsource/modules160-170.rst +++ b/docsource/modules160-170.rst @@ -196,7 +196,7 @@ Module coverage 16.0 -> 17.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | hr_skills_survey | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| hr_timesheet | | | +| hr_timesheet | Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | hr_timesheet_attendance | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..dd2e7c3781e9 --- /dev/null +++ b/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/post-migration.py @@ -0,0 +1,31 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# Copyright 2025 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def _project_update_fill_timesheet(env): + """Fill existing project updates with the theoretical information about the number + of allocated and spent hours. It may be different from the ones existing on the + moment the project update was done if later modifications changed them. + """ + uom_hour = env.ref("uom.product_uom_hour") + for update in env["project.update"].with_context(active_test=False).search([]): + project = update.project_id + group = env["account.analytic.line"]._read_group( + [("project_id", "=", project.id), ("date", "<=", update.date)], + [], + ["unit_amount:sum"], + )[0] + update.write( + { + "uom_id": uom_hour.id, + "allocated_time": round(project.allocated_hours), + "timesheet_time": round(group[0]), + } + ) + + +@openupgrade.migrate() +def migrate(env, version): + _project_update_fill_timesheet(env) diff --git a/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..172b4d1e6bc4 --- /dev/null +++ b/openupgrade_scripts/scripts/hr_timesheet/17.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,37 @@ +---Models in module 'hr_timesheet'--- +new model hr.employee.delete.wizard [transient] +# NOTHING TO DO + +---Fields in module 'hr_timesheet'--- +hr_timesheet / account.analytic.line / ancestor_task_id (many2one) : DEL relation: project.task +# NOTHING TO DO: Removed field + +hr_timesheet / account.analytic.line / parent_task_id (many2one) : NEW relation: project.task, isrelated: related, stored +# NOTHING TO DO: ORM already fills it efficiently being a 2 level depth related field + +hr_timesheet / project.project / timesheet_encode_uom_id (many2one): not related anymore +hr_timesheet / project.project / timesheet_encode_uom_id (many2one): now a function +# NOTHING TO DO: non stored field + +hr_timesheet / project.update / allocated_time (integer) : NEW +hr_timesheet / project.update / timesheet_time (integer) : NEW +hr_timesheet / project.update / uom_id (many2one) : NEW relation: uom.uom +# DONE: post-migration: fill historical values with the aproximation of current data (there can be differences if in the moment of creating the update, the allocated hours or the timesheets were not the same as today) + +---XML records in module 'hr_timesheet'--- +DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_from_employee_list +NEW ir.actions.server: hr_timesheet.unlink_employee_action +NEW ir.model.access: hr_timesheet.access_hr_employee_delete_wizard +DEL ir.model.access: hr_timesheet.access_project_task +NEW ir.ui.view: hr_timesheet.hr_employee_delete_wizard_form +NEW ir.ui.view: hr_timesheet.portal_my_task_allocated_hours_template +NEW ir.ui.view: hr_timesheet.project_update_view_kanban_inherit +NEW ir.ui.view: hr_timesheet.view_employee_tree_inherit_timesheet +DEL ir.ui.view: hr_timesheet.portal_my_task_planned_hours_template +DEL ir.ui.view: hr_timesheet.project_sharing_inherit_project_task_view_tree +DEL ir.ui.view: hr_timesheet.project_sharing_project_task_view_search_inherit_timesheet +DEL ir.ui.view: hr_timesheet.rating_rating_view_search_project_inherited +DEL ir.ui.view: hr_timesheet.report_project_task_user_view_search +DEL ir.ui.view: hr_timesheet.report_project_task_user_view_tree +DEL ir.ui.view: hr_timesheet.view_task_search_form_hr_extended +# NOTHING TO DO: noupdate=0 records