Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---Fields in module 'hr_attendance'---
hr_attendance / hr.attendance / action (selection) : DEL required: required, selection_keys: ['action', 'sign_in', 'sign_out']
# DONE: pre-migration: rename columns

hr_attendance / hr.attendance / action_desc (many2one) : DEL relation: hr.action.reason
# NOTHING TO DO: hr.action.reason model doesn't exist anymore

hr_attendance / hr.attendance / name (datetime) : DEL required: required, req_default: function
hr_attendance / hr.attendance / check_in (datetime) : NEW required: required, req_default: function
hr_attendance / hr.attendance / check_out (datetime) : NEW
# DONE: 'name' column renamed to 'check_in'
# DONE: Move name value to check_out column in matching 'sign_in' record for records where action='sign_out'

hr_attendance / hr.employee / attendance_ids (one2many) : NEW relation: hr.attendance
# NOTHING TO DO

hr_attendance / hr.employee / barcode (char) : NEW
# NOTHING TO DO

hr_attendance / hr.employee / pin (char) : NEW
# NOTHING TO DO

---XML records in module 'hr_attendance'---
NEW ir.actions.act_window: hr_attendance.action_hr_attendance_settings
NEW ir.actions.act_window: hr_attendance.hr_attendance_action
NEW ir.actions.act_window: hr_attendance.hr_attendance_action_graph
NEW ir.actions.act_window: hr_attendance.hr_attendance_action_graph_filtered
NEW ir.actions.act_window: hr_attendance.hr_employee_attendance_action_kanban
# NOTHING TO DO

DEL ir.actions.act_window: hr_attendance.action_hr_attendance_error
DEL ir.actions.act_window: hr_attendance.action_hr_attendance_graph
DEL ir.actions.act_window: hr_attendance.action_hr_attendance_graph_filtered
DEL ir.actions.act_window: hr_attendance.open_view_attendance
DEL ir.actions.act_window: hr_attendance.open_view_attendance_reason
# NOTHING TO DO

NEW ir.actions.client: hr_attendance.hr_attendance_action_greeting_message
NEW ir.actions.client: hr_attendance.hr_attendance_action_kiosk_mode
NEW ir.actions.client: hr_attendance.hr_attendance_action_my_attendances
NEW ir.actions.report.xml: hr_attendance.hr_employee_print_badge
# NOTHING TO DO

DEL ir.actions.report.xml: hr_attendance.action_report_hrattendanceerror
# NOTHING TO DO

DEL ir.model.access: hr_attendance.access_hr_action_reason_employee
DEL ir.model.access: hr_attendance.access_hr_action_reason_user
# NOTHING TO DO

NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_employee
NEW ir.rule: hr_attendance.hr_attendance_rule_attendance_manager
# NOTHING TO DO
DEL ir.rule: hr_attendance.property_rule_attendace_employee
DEL ir.rule: hr_attendance.property_rule_attendace_manager
# DONE: delete

NEW ir.ui.menu: hr_attendance.menu_hr_attendance_kiosk_mode
NEW ir.ui.menu: hr_attendance.menu_hr_attendance_manage_attendances
NEW ir.ui.menu: hr_attendance.menu_hr_attendance_my_attendances
NEW ir.ui.menu: hr_attendance.menu_hr_attendance_settings
NEW ir.ui.menu: hr_attendance.menu_hr_attendance_view_attendances
NEW ir.ui.menu: hr_attendance.menu_hr_attendance_view_employees_kanban
DEL ir.ui.menu: hr_attendance.menu_hr_attendance_config
DEL ir.ui.menu: hr_attendance.menu_hr_time_tracking
DEL ir.ui.menu: hr_attendance.menu_open_view_attendance
DEL ir.ui.menu: hr_attendance.timesheet_menu_root
# NOTHING TO DO

NEW ir.ui.view: hr_attendance.hr_attendance_view_config
NEW ir.ui.view: hr_attendance.hr_attendance_view_filter
NEW ir.ui.view: hr_attendance.hr_attendance_view_form
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.hr_employees_view_kanban
NEW ir.ui.view: hr_attendance.print_employee_badge
NEW ir.ui.view: hr_attendance.view_employee_form_inherit_hr_attendance
NEW ir.ui.view: hr_attendance.view_employee_kanban_inherit_hr_attendance
DEL ir.ui.view: hr_attendance.edit_attendance_reason
DEL ir.ui.view: hr_attendance.report_attendanceerrors
DEL ir.ui.view: hr_attendance.view_attendance_form
DEL ir.ui.view: hr_attendance.view_attendance_reason
DEL ir.ui.view: hr_attendance.view_attendance_who
DEL ir.ui.view: hr_attendance.view_hr_attendance_error
DEL ir.ui.view: hr_attendance.view_hr_attendance_filter
DEL ir.ui.view: hr_attendance.view_hr_attendance_graph
DEL ir.ui.view: hr_attendance.view_hr_attendance_pivot
# NOTHING TO DO

DEL ir.values: hr_attendance.hr_attendance_error_values
# NOTHING TO DO

NEW res.groups: hr.group_hr_attendance
NEW res.groups: hr_attendance.group_hr_attendance_manager
NEW res.groups: hr_attendance.group_hr_attendance_use_pin
NEW res.groups: hr_attendance.group_hr_attendance_user
DEL res.groups: base.group_hr_manager
NEW res.users: base.default_user
# NOTHING TO DO
31 changes: 31 additions & 0 deletions addons/hr_attendance/migrations/10.0.2.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


def assign_check_out(env):
"""Move name value to check_out column in matching 'sign_in' record for
records where action='sign_out'.
"""
openupgrade.logged_query(
env.cr,
"""UPDATE hr_attendance a
SET check_out = (
SELECT name
FROM %s
WHERE action = 'sign_out'
AND name > a.check_in
AND employee_id = a.employee_id
LIMIT 1
)
""" % openupgrade.get_legacy_name('hr_attendance')
)
# Recompute worked hours
env['hr.attendance'].search([])._compute_worked_hours()


@openupgrade.migrate()
def migrate(env, version):
assign_check_out(env)
33 changes: 33 additions & 0 deletions addons/hr_attendance/migrations/10.0.2.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Vicent Cubells
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade

_column_renames = {
'hr_attendance': [
('name', 'check_in'),
],
}


@openupgrade.migrate()
def migrate(env, version):
# As there are indexes, foreign keys, and so on, we need to keep the
# original table, copy it and remove records, instead of renaming and copy
# only sign in records
openupgrade.logged_query(
env.cr,
"""CREATE TABLE %s AS (
SELECT * FROM hr_attendance
)""" % openupgrade.get_legacy_name('hr_attendance')
)
openupgrade.logged_query(
env.cr,
"""DELETE FROM hr_attendance
WHERE action != 'sign_in'"""
)
openupgrade.rename_columns(env.cr, _column_renames)
env.ref('hr_attendance.property_rule_attendace_manager').unlink()
env.ref('hr_attendance.property_rule_attendace_employee').unlink()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# coding: utf-8
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase


class TestHrAttendance(TransactionCase):
def test_check_out(self):
att1 = self.env.ref('hr_attendance.attendance1')
self.assertEqual(att1.check_out[-11:], '01 11:51:00')
self.assertAlmostEqual(att1.worked_hours, 3.5, 1)
att2 = self.env.ref('hr_attendance.attendance3')
self.assertEqual(att2.check_out[-11:], '02 19:53:00')
self.assertAlmostEqual(att2.worked_hours, 7.1, 1)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules90-100.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ missing in the new release are marked with |del|.
+-----------------------------------+-----------------------------------+
|hr | Done |
+-----------------------------------+-----------------------------------+
|hr_attendance | |
|hr_attendance | Done |
+-----------------------------------+-----------------------------------+
|hr_contract | Nothing to do |
+-----------------------------------+-----------------------------------+
Expand Down