-
-
Notifications
You must be signed in to change notification settings - Fork 785
[17.0][OU-ADD] hr_attendance #4801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
openupgrade_scripts/scripts/hr_attendance/17.0.2.0/post-migration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
| import uuid | ||
|
|
||
| from openupgradelib import openupgrade | ||
|
|
||
| _deleted_xml_records = [ | ||
| "hr_attendance.hr_attendance_report_rule_multi_company", | ||
| "hr_attendance.hr_attendance_rule_attendance_employee", | ||
| "hr_attendance.hr_attendance_rule_attendance_manager", | ||
| "hr_attendance.hr_attendance_rule_attendance_manual", | ||
| "hr_attendance.hr_attendance_rule_attendance_overtime_employee", | ||
| "hr_attendance.hr_attendance_rule_attendance_overtime_manager", | ||
| ] | ||
|
|
||
|
|
||
| def fill_res_company_hr_attendance_display_overtime(env): | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| UPDATE res_company | ||
| SET hr_attendance_display_overtime = hr_attendance_overtime | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| def fill_res_company_attendance_kiosk_use_pin(env): | ||
| group = env.ref("hr_attendance.group_hr_attendance_use_pin") | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| f""" | ||
| UPDATE res_company rc | ||
| SET attendance_kiosk_use_pin = TRUE | ||
| FROM res_users ru | ||
| JOIN res_groups_users_rel group_rel ON group_rel.uid = ru.id | ||
| AND group_rel.gid = {group.id} | ||
| JOIN res_company_users_rel company_rel ON company_rel.user_id = ru.id | ||
| WHERE company_rel.cid = rc.id AND ru.active | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| def fill_res_company_attendance_kiosk_key(env): | ||
| companies = env["res.company"].search([]) | ||
| for company in companies: | ||
| company.attendance_kiosk_key = uuid.uuid4().hex | ||
|
|
||
|
|
||
| def fill_hr_attendance_overtime_hours(env): | ||
| attendances = env["hr.attendance"].search([]) | ||
| # this way, the query in the compute method only is executed once | ||
| attendances._compute_overtime_hours() | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| fill_res_company_hr_attendance_display_overtime(env) | ||
| fill_res_company_attendance_kiosk_use_pin(env) | ||
| fill_res_company_attendance_kiosk_key(env) | ||
| openupgrade.delete_records_safely_by_xml_id(env, _deleted_xml_records) | ||
| fill_hr_attendance_overtime_hours(env) | ||
46 changes: 46 additions & 0 deletions
46
openupgrade_scripts/scripts/hr_attendance/17.0.2.0/pre-migration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
| from openupgradelib import openupgrade | ||
|
|
||
| _xmlid_renames = [ | ||
| ( | ||
| "hr_attendance.group_hr_attendance_user", | ||
| "hr_attendance.group_hr_attendance_officer", | ||
| ), | ||
| ( | ||
| "hr_attendance.group_hr_attendance_kiosk", | ||
| "hr_attendance.group_hr_attendance_own_reader", | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
| def pre_create_hr_attendance_overtime_hours(env): | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| ALTER TABLE hr_attendance | ||
| ADD COLUMN IF NOT EXISTS overtime_hours numeric | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| def fill_res_company_attendance_from_systray(env): | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| ALTER TABLE res_company ADD COLUMN attendance_from_systray boolean DEFAULT true | ||
| """, | ||
| ) | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| """ | ||
| ALTER TABLE res_company ALTER COLUMN attendance_from_systray DROP DEFAULT | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| openupgrade.rename_xmlids(env.cr, _xmlid_renames) | ||
| pre_create_hr_attendance_overtime_hours(env) | ||
| fill_res_company_attendance_from_systray(env) |
108 changes: 108 additions & 0 deletions
108
openupgrade_scripts/scripts/hr_attendance/17.0.2.0/upgrade_analysis_work.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| ---Models in module 'hr_attendance'--- | ||
| obsolete model hr.attendance.report [sql_view] | ||
| ---Fields in module 'hr_attendance'--- | ||
| hr_attendance / hr.attendance / message_follower_ids (one2many): NEW relation: mail.followers | ||
| hr_attendance / hr.attendance / message_ids (one2many) : NEW relation: mail.message | ||
| hr_attendance / hr.attendance / rating_ids (one2many) : NEW relation: rating.rating | ||
| hr_attendance / hr.attendance / website_message_ids (one2many): NEW relation: mail.message | ||
| # NOTHING TO DO | ||
|
|
||
| hr_attendance / hr.attendance / in_browser (char) : NEW | ||
| hr_attendance / hr.attendance / in_city (char) : NEW | ||
| hr_attendance / hr.attendance / in_country_name (char) : NEW | ||
| hr_attendance / hr.attendance / in_ip_address (char) : NEW | ||
| hr_attendance / hr.attendance / in_latitude (float) : NEW | ||
| hr_attendance / hr.attendance / in_longitude (float) : NEW | ||
| hr_attendance / hr.attendance / in_mode (selection) : NEW selection_keys: ['kiosk', 'manual', 'systray'] | ||
| hr_attendance / hr.attendance / out_browser (char) : NEW | ||
| hr_attendance / hr.attendance / out_city (char) : NEW | ||
| hr_attendance / hr.attendance / out_country_name (char) : NEW | ||
| hr_attendance / hr.attendance / out_ip_address (char) : NEW | ||
| hr_attendance / hr.attendance / out_latitude (float) : NEW | ||
| hr_attendance / hr.attendance / out_longitude (float) : NEW | ||
| hr_attendance / hr.attendance / out_mode (selection) : NEW selection_keys: ['kiosk', 'manual', 'systray'] | ||
| # NOTHING TO DO: new feature (Geolocation information) | ||
|
|
||
| hr_attendance / hr.attendance / overtime_hours (float) : NEW isfunction: function, stored | ||
| # DONE: pre-migration: Pre-create the column for not triggering the method for each record (as it is costly) | ||
| # DONE: post-migration: Fill column in one call | ||
|
|
||
| hr_attendance / hr.employee / attendance_manager_id (many2one): NEW relation: res.users | ||
| # NOTHING TO DO | ||
|
|
||
| hr_attendance / res.company / attendance_from_systray (boolean): NEW hasdefault: default | ||
| # DONE: pre-migration: fill default values | ||
|
|
||
| hr_attendance / res.company / attendance_kiosk_key (char) : NEW hasdefault: default | ||
| # DONE: post-migration: fill default values | ||
|
|
||
| hr_attendance / res.company / attendance_kiosk_use_pin (boolean): NEW | ||
MiquelRForgeFlow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DEL res.groups: hr_attendance.group_hr_attendance_use_pin | ||
| DONE: post-migration: fill if user was in group hr_attendance.group_hr_attendance_use_pin | ||
|
|
||
| hr_attendance / res.company / hr_attendance_display_overtime (boolean): NEW | ||
| # DONE: post-migration: maintain v16 usability, which was using hr_attendance_overtime | ||
|
|
||
| ---XML records in module 'hr_attendance'--- | ||
| NEW ir.actions.act_window: hr_attendance.hr_attendance_reporting | ||
| DEL ir.actions.act_window: hr_attendance.hr_attendance_action_employee | ||
| DEL ir.actions.act_window: hr_attendance.hr_attendance_action_overview | ||
| DEL ir.actions.act_window: hr_attendance.hr_attendance_report_action | ||
| DEL ir.actions.act_window: hr_attendance.hr_attendance_report_action_filtered | ||
| # NOTHING TO DO | ||
|
|
||
| DEL ir.actions.client: hr_attendance.hr_attendance_action_kiosk_mode | ||
| DEL ir.actions.client: hr_attendance.hr_attendance_action_my_attendances | ||
| NEW ir.actions.server: hr_attendance.open_kiosk_url | ||
| # NOTHING TO DO | ||
|
|
||
| NEW ir.model.access: hr_attendance.access_hr_attendance_admin | ||
| NEW ir.model.access: hr_attendance.access_hr_attendance_admin_overtime | ||
| NEW ir.model.access: hr_attendance.access_hr_attendance_officer_overtime | ||
| DEL ir.model.access: hr_attendance.access_hr_attendance_overtime_system_user | ||
| DEL ir.model.access: hr_attendance.access_hr_attendance_report_user | ||
| DEL ir.model.access: hr_attendance.access_hr_attendance_system_user | ||
| # NOTHING TO DO | ||
|
|
||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_admin (noupdate) | ||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_manager_restrict (noupdate) | ||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_officer_overtime_restrict (noupdate) | ||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_overtime_admin (noupdate) | ||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_overtime_simple_user (noupdate) | ||
| NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_simple_user (noupdate) | ||
| # NOTHING TO DO | ||
|
|
||
| DEL ir.rule: hr_attendance.hr_attendance_report_rule_multi_company (noupdate) | ||
pedrobaeza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DEL ir.rule: hr_attendance.hr_attendance_rule_attendance_employee (noupdate) | ||
| DEL ir.rule: hr_attendance.hr_attendance_rule_attendance_manager (noupdate) | ||
| DEL ir.rule: hr_attendance.hr_attendance_rule_attendance_manual (noupdate) | ||
| DEL ir.rule: hr_attendance.hr_attendance_rule_attendance_overtime_employee (noupdate) | ||
| DEL ir.rule: hr_attendance.hr_attendance_rule_attendance_overtime_manager (noupdate) | ||
| # DONE: post-migration: safely delete | ||
|
|
||
| NEW ir.ui.menu: hr_attendance.menu_hr_attendance_reporting | ||
| DEL ir.ui.menu: hr_attendance.menu_hr_attendance_attendances_overview | ||
| DEL ir.ui.menu: hr_attendance.menu_hr_attendance_my_attendances | ||
| DEL ir.ui.menu: hr_attendance.menu_hr_attendance_report | ||
| # NOTHING TO DO | ||
|
|
||
| NEW ir.ui.view: hr_attendance.hr_attendance_employee_simple_tree_view | ||
| NEW ir.ui.view: hr_attendance.hr_attendance_view_graph | ||
| NEW ir.ui.view: hr_attendance.hr_attendance_view_pivot | ||
| NEW ir.ui.view: hr_attendance.public_kiosk_mode | ||
| NEW ir.ui.view: hr_attendance.view_employee_tree_inherit_leave | ||
| DEL ir.ui.view: hr_attendance.hr_attendance_report_view_graph | ||
| DEL ir.ui.view: hr_attendance.hr_attendance_report_view_pivot | ||
| DEL ir.ui.view: hr_attendance.hr_attendance_report_view_search | ||
| # NOTHING TO DO | ||
|
|
||
| NEW res.groups: hr_attendance.group_hr_attendance_officer | ||
| DEL res.groups: hr_attendance.group_hr_attendance_user | ||
| # DONE: pre-migration: rename group | ||
|
|
||
| NEW res.groups: hr_attendance.group_hr_attendance_own_reader | ||
| DEL res.groups: hr_attendance.group_hr_attendance_kiosk | ||
| # DONE: pre-migration: rename group | ||
|
|
||
| DEL res.groups: hr_attendance.group_hr_attendance | ||
| # NOTHING TO DO | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.