Skip to content
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

[16.0][OU-ADD] hr_timesheet #4029

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| hr_skills_survey | |No DB layout changes. |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| hr_timesheet | | |
| hr_timesheet | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| hr_timesheet_attendance | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
76 changes: 76 additions & 0 deletions openupgrade_scripts/scripts/hr_timesheet/16.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from openupgradelib import openupgrade


def update_rename_field(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE hr_employee
ADD COLUMN IF NOT EXISTS hourly_cost numeric
""",
)

openupgrade.logged_query(
env.cr,
"""
UPDATE hr_employee
SET hourly_cost = timesheet_cost
""",
)


def create_ancestor_task_id(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_analytic_line
ADD COLUMN IF NOT EXISTS ancestor_task_id integer
""",
)

openupgrade.logged_query(
env.cr,
"""
UPDATE account_analytic_line AS aal
SET ancestor_task_id = pt.ancestor_id
FROM project_task AS pt
WHERE pt.id = aal.task_id
""",
)


def create_manager_id(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_analytic_line
ADD COLUMN IF NOT EXISTS manager_id integer
""",
)

openupgrade.logged_query(
env.cr,
"""
UPDATE account_analytic_line AS aal
SET manager_id = he.parent_id
FROM hr_employee AS he
WHERE he.id = aal.employee_id
""",
)


def delete_constraint_project_task_create_timesheet_time_positive(env):
openupgrade.delete_sql_constraint_safely(
env,
"hr_timesheet",
"project_task",
"create_timesheet_time_positive",
)


@openupgrade.migrate()
def migrate(env, version):
update_rename_field(env)
create_ancestor_task_id(env)
create_manager_id(env)
delete_constraint_project_task_create_timesheet_time_positive(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---Models in module 'hr_timesheet'---
obsolete model project.task.create.timesheet [transient]
new model timesheets.analysis.report [sql_view]

# NOTHING TO DO

---Fields in module 'hr_timesheet'---
hr_timesheet / account.analytic.line / ancestor_task_id (many2one) : NEW relation: project.task, isrelated: related, stored
hr_timesheet / account.analytic.line / manager_id (many2one) : NEW relation: hr.employee, isrelated: related, stored

# DONE: create column and load data in pre-migration

hr_timesheet / account.analytic.line / partner_id (False) : module is now 'account' ('hr_timesheet')
hr_timesheet / hr.employee / currency_id (many2one) : module is now 'hr_hourly_cost' ('hr_timesheet')

# NOTHING TO DO

hr_timesheet / hr.employee / timesheet_cost (float) : DEL

# DONE: changed to hourly_cost field in pre-migration

hr_timesheet / project.project / allocated_hours (float) : NEW

# NOTHING TO DO: remove in master

hr_timesheet / project.project / timesheet_count (boolean) : type is now 'integer' ('boolean')

# NOTHING TO DO: field store = False

---XML records in module 'hr_timesheet'---
NEW ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_line_by_project_view_form
NEW ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_line_by_project_view_graph
NEW ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_line_by_project_view_kanban
NEW ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_line_by_project_view_pivot
NEW ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_line_by_project_view_tree
DEL ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_report_form
DEL ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_report_kanban
DEL ir.actions.act_window.view: hr_timesheet.act_hr_timesheet_report_tree
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_project_form
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_project_kanban
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_project_tree
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_task_form
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_task_kanban
DEL ir.actions.act_window.view: hr_timesheet.timesheet_action_view_report_by_task_tree
NEW ir.actions.report: hr_timesheet.timesheet_report_task_timesheets
NEW ir.model.access: hr_timesheet.access_timesheets_analysis_report_manager
NEW ir.model.access: hr_timesheet.access_timesheets_analysis_report_user
DEL ir.model.access: hr_timesheet.access_project_task_create_timesheet

# NOTHING TO DO

DEL ir.model.constraint: hr_timesheet.constraint_project_task_create_timesheet_time_positive

# DONE : delete safely in pre-migration

NEW ir.rule: hr_timesheet.timesheets_analysis_report_comp_rule (noupdate)
NEW ir.ui.view: hr_timesheet.hr_timesheet_report_search
NEW ir.ui.view: hr_timesheet.project_project_view_tree_inherit_sale_project
NEW ir.ui.view: hr_timesheet.project_sharing_project_task_view_search_inherit_timesheet
NEW ir.ui.view: hr_timesheet.project_update_view_search_inherit
NEW ir.ui.view: hr_timesheet.rating_rating_view_search_project_inherited
NEW ir.ui.view: hr_timesheet.report_timesheet_task
NEW ir.ui.view: hr_timesheet.timesheet_project_task_page
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_graph_employee
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_graph_project
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_graph_task
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_pivot_employee
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_pivot_project
NEW ir.ui.view: hr_timesheet.timesheets_analysis_report_pivot_task
NEW ir.ui.view: hr_timesheet.view_hr_timesheet_line_graph_by_employee
NEW ir.ui.view: hr_timesheet.view_project_project_filter_inherit_timesheet
NEW ir.ui.view: hr_timesheet.view_task_search_form_hr_extended
DEL ir.ui.view: hr_timesheet.project_sharing_inherit_project_task_view_search
DEL ir.ui.view: hr_timesheet.project_task_create_timesheet_view_form

# NOTHING TO DO
Loading