From eeb4a40b69fc34bf4949a3d2b6c3b832295e5aee Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Thu, 3 Sep 2020 12:52:45 -0700 Subject: [PATCH] [IMP] hr_payroll_attendance: Migration script for 13 --- hr_payroll_attendance/__init__.py | 18 ++++++++++++++++++ hr_payroll_attendance/__manifest__.py | 1 + .../migrations/13.0.0.0.1/pre-migration.py | 6 ++++++ 3 files changed, 25 insertions(+) create mode 100644 hr_payroll_attendance/migrations/13.0.0.0.1/pre-migration.py diff --git a/hr_payroll_attendance/__init__.py b/hr_payroll_attendance/__init__.py index 0650744f..4e3ff034 100755 --- a/hr_payroll_attendance/__init__.py +++ b/hr_payroll_attendance/__init__.py @@ -1 +1,19 @@ from . import models + + +def attn_payroll_pre_init_hook(cr): + """ + This module installs a Work Entry Type with code "ATTN" + If you have undergone a migration (either for this module + or even your own Payslip Work Entry lines with code "ATTN") + then the uniqueness constraint will prevent this module + from installing. + """ + cr.execute("UPDATE hr_work_entry_type " + "SET code = 'ATTN-PRE-INSTALL' " + "WHERE code = 'ATTN';" + ) + cr.execute("UPDATE hr_work_entry_type " + "SET code = 'ATTN_OT-PRE-INSTALL' " + "WHERE code = 'ATTN_OT';" + ) diff --git a/hr_payroll_attendance/__manifest__.py b/hr_payroll_attendance/__manifest__.py index 6b18d0a3..3a1be326 100755 --- a/hr_payroll_attendance/__manifest__.py +++ b/hr_payroll_attendance/__manifest__.py @@ -17,4 +17,5 @@ 'hr_attendance', 'hr_payroll_overtime', ], + 'pre_init_hook': 'attn_payroll_pre_init_hook', } diff --git a/hr_payroll_attendance/migrations/13.0.0.0.1/pre-migration.py b/hr_payroll_attendance/migrations/13.0.0.0.1/pre-migration.py new file mode 100644 index 00000000..6c081185 --- /dev/null +++ b/hr_payroll_attendance/migrations/13.0.0.0.1/pre-migration.py @@ -0,0 +1,6 @@ + +def migrate(cr, version): + # pre_init_hook script only runs on install, + # if you're coming from 12.0 we need the same change + from odoo.addons.hr_payroll_timesheet import attn_payroll_pre_init_hook + attn_payroll_pre_init_hook(cr)