From 93c85ff0804526f6c487fdf24f77fabe87cfc2f9 Mon Sep 17 00:00:00 2001
From: "Pedro M. Baeza" <pedro.baeza@tecnativa.com>
Date: Fri, 25 Jul 2025 20:44:54 +0200
Subject: [PATCH] [OU-ADD hr_skills_survey: Migration scripts

TT54662
---
 docsource/modules160-170.rst                  |  2 +-
 .../17.0.1.0/pre-migration.py                 | 22 +++++++++++++++++++
 .../17.0.1.0/upgrade_analysis_work.txt        | 14 ++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/pre-migration.py
 create mode 100644 openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/upgrade_analysis_work.txt

diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst
index b0ea971066cd..97e8cdbf059e 100644
--- a/docsource/modules160-170.rst
+++ b/docsource/modules160-170.rst
@@ -194,7 +194,7 @@ Module coverage 16.0 -> 17.0
 +---------------------------------------------------+----------------------+-------------------------------------------------+
 | hr_skills_slides                                  |                      |No DB layout changes.                            |
 +---------------------------------------------------+----------------------+-------------------------------------------------+
-| hr_skills_survey                                  |                      |                                                 |
+| hr_skills_survey                                  | Done                 |                                                 |
 +---------------------------------------------------+----------------------+-------------------------------------------------+
 | hr_timesheet                                      | Done                 |                                                 |
 +---------------------------------------------------+----------------------+-------------------------------------------------+
diff --git a/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/pre-migration.py
new file mode 100644
index 000000000000..8884d20ba429
--- /dev/null
+++ b/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/pre-migration.py
@@ -0,0 +1,22 @@
+# Copyright 2025 Tecnativa - Pedro M. Baeza
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+from openupgradelib import openupgrade
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+    openupgrade.add_columns(
+        env, [(False, "expiration_status", "char", "valid", "hr_resume_line")]
+    )
+    openupgrade.logged_query(
+        env.cr,
+        """
+        UPDATE hr_resume_line
+        SET expiration_status = CASE
+            WHEN date_end <= now() at time zone 'utc' THEN 'expired'
+            WHEN date_end <= (now() - INTERVAL '3 MONTHS') at time zone 'utc'
+                THEN 'expiring'
+        END
+        WHERE date_end IS NOT NULL
+        """,
+    )
diff --git a/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/upgrade_analysis_work.txt
new file mode 100644
index 000000000000..87fae1a990b7
--- /dev/null
+++ b/openupgrade_scripts/scripts/hr_skills_survey/17.0.1.0/upgrade_analysis_work.txt
@@ -0,0 +1,14 @@
+---Models in module 'hr_skills_survey'---
+---Fields in module 'hr_skills_survey'---
+hr_skills_survey / hr.resume.line           / department_id (many2one)      : NEW relation: hr.department, isrelated: related, stored
+# NOTHING TO DO: ORM already handles this efficiently with a SQL initializing the field
+
+hr_skills_survey / hr.resume.line           / expiration_status (selection) : NEW selection_keys: ['expired', 'expiring', 'valid'], isfunction: function, stored
+# DONE: pre-migration: Pre-created and fast-filled
+
+---XML records in module 'hr_skills_survey'---
+NEW ir.actions.act_window: hr_skills_survey.hr_employee_certification_report_action
+NEW ir.ui.menu: hr_skills_survey.hr_employee_certication_report_menu
+NEW ir.ui.view: hr_skills_survey.hr_employee_certification_report_view_list
+NEW ir.ui.view: hr_skills_survey.hr_resume_line_view_search
+# NOTHING TO DO: new ir stuff
