Skip to content

Commit

Permalink
[MIG] hr_attendance_report_theoretical_time: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjosesegui-tecnativa committed Aug 13, 2024
1 parent a64dba3 commit 4b37c66
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 55 deletions.
1 change: 1 addition & 0 deletions hr_attendance_report_theoretical_time/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Contributors
- Pedro M. Baeza.
- David Vidal
- Víctor Martínez
- Juan José Seguí

- Pedro Gonzalez <[email protected]>
- Aritz Olea <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion hr_attendance_report_theoretical_time/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Theoretical vs Attended Time Analysis",
"version": "16.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/hr-attendance",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
9 changes: 9 additions & 0 deletions hr_attendance_report_theoretical_time/models/hr_attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ def _compute_theoretical_hours(self):
record.theoretical_hours = obj._theoretical_hours(
record.employee_id, record.check_in
)

@api.model
def _select(self):
return super()._select() + """, hra.theoretical_hours"""

Check warning on line 24 in hr_attendance_report_theoretical_time/models/hr_attendance.py

View check run for this annotation

Codecov / codecov/patch

hr_attendance_report_theoretical_time/models/hr_attendance.py#L24

Added line #L24 was not covered by tests

@api.model
def _from(self):
res = super()._from()
return res.replace("worked_hours", "worked_hours, theoretical_hours")

Check warning on line 29 in hr_attendance_report_theoretical_time/models/hr_attendance.py

View check run for this annotation

Codecov / codecov/patch

hr_attendance_report_theoretical_time/models/hr_attendance.py#L28-L29

Added lines #L28 - L29 were not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Pedro M. Baeza.
- David Vidal
- Víctor Martínez
- Juan José Seguí
- Pedro Gonzalez \<<[email protected]>\>
- Aritz Olea \<<[email protected]>\>
- [Trobz](https://trobz.com):
Expand Down
1 change: 0 additions & 1 deletion hr_attendance_report_theoretical_time/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import hr_attendance_report
from . import hr_attendance_theoretical_time_report

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<field
name="name"
>hr.attendance.pivot - Don't show "Theoretical hours" measure</field>
<field name="model">hr.attendance.report</field>
<field name="inherit_id" ref="hr_attendance.hr_attendance_report_view_pivot" />
<field name="model">hr.attendance</field>
<field name="inherit_id" ref="hr_attendance.hr_attendance_view_pivot" />
<field name="arch" type="xml">
<field name="worked_hours" position="after">
<field name="theoretical_hours" invisible="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def read_group(
This technique has proven to be more efficient than trying to call
recursively `read_group` grouping by date and employee.
"""
res = super(HrAttendanceTheoreticalTimeReport, self).read_group(
res = super().read_group(
domain,
fields,
groupby,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<record id="hr_attendance_theoretical_view_pivot" model="ir.ui.view">
<field name="model">hr.attendance.theoretical.time.report</field>
<field name="arch" type="xml">
<pivot disable_linking="1">
<pivot>
<field name="employee_id" type="row" />
<field name="department_id" />
<field name="date" type="col" />
Expand Down Expand Up @@ -67,38 +67,42 @@
name="context"
>{'search_default_previous_month': 1, 'search_default_current_month': 1, 'search_default_my': 1}</field>
<field name="view_mode">pivot,graph</field>
<field
name="view_ids"
eval="[(5, 0, 0), (0, 0, {'view_mode': 'pivot', 'view_id': ref('hr_attendance_theoretical_view_pivot')}), (0, 0, {'view_mode': 'graph', 'view_id': ref('hr_attendance_theoretical_view_graph')})]"
/>
</record>
<record id="hr_attendance.menu_hr_attendance_report" model="ir.ui.menu">
<record id="hr_attendance.menu_hr_attendance_reporting" model="ir.ui.menu">
<field
name="groups_id"
eval="[(4, ref('hr_attendance.group_hr_attendance'))]"
eval="[(4, ref('hr_attendance.group_hr_attendance_officer'))]"
/>
<!-- We need to leave the action empty for consistency because we are going
to set different submenus, otherwise the Reports menu would not be
displayed to a basic user. !-->
<field name="action" eval="False" />
</record>
<menuitem
id="menu_hr_attendance_report"
id="menu_hr_attendance_reporting"
name="Attendances Analysis"
parent="hr_attendance.menu_hr_attendance_report"
sequence="10"
groups="hr_attendance.group_hr_attendance_user"
action="hr_attendance.hr_attendance_report_action"
parent="hr_attendance.menu_hr_attendance_reporting"
sequence="05"
groups="hr_attendance.group_hr_attendance_officer"
action="hr_attendance.hr_attendance_reporting"
/>
<menuitem
id="menu_hr_attendance_theoretical_root"
name="Theoretical vs Attended Time"
parent="hr_attendance.menu_hr_attendance_report"
sequence="15"
groups="hr_attendance.group_hr_attendance"
parent="hr_attendance.menu_hr_attendance_reporting"
sequence="10"
groups="hr_attendance.group_hr_attendance_officer"
/>
<menuitem
id="menu_hr_attendance_theoretical_report"
name="Analysis"
action="hr_attendance_theoretical_action"
parent="menu_hr_attendance_theoretical_root"
groups="hr_attendance.group_hr_attendance"
sequence="20"
groups="hr_attendance.group_hr_attendance_officer"
sequence="15"
/>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
<record model="ir.rule" id="rule_theoretical_vs_worked_report_own">
<field name="name">Theoretical vs worked hours: Own attendances</field>
<field name="model_id" ref="model_hr_attendance_theoretical_time_report" />
<field name="groups" eval="[(4, ref('hr_attendance.group_hr_attendance'))]" />
<field
name="groups"
eval="[(4, ref('hr_attendance.group_hr_attendance_own_reader'))]"
/>
<field name="domain_force">[['employee_id.user_id', '=', user.id]]</field>
</record>
<record model="ir.rule" id="rule_theoretical_vs_worked_report_all">
<field name="name">Theoretical vs worked hours: All attendances</field>
<field name="model_id" ref="model_hr_attendance_theoretical_time_report" />
<field
name="groups"
eval="[(4, ref('hr_attendance.group_hr_attendance_user'))]"
eval="[(4, ref('hr_attendance.group_hr_attendance_officer'))]"
/>
<field name="domain_force">[[1, '=', 1]]</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_attendance_theoretical_time_report,access_hr_attendance_theoretical_time_report,model_hr_attendance_theoretical_time_report,hr_attendance.group_hr_attendance,1,0,0,0
access_wizard_theoretical_time,access_wizard_theoretical_time,model_wizard_theoretical_time,hr_attendance.group_hr_attendance_user,1,1,1,1
access_hr_attendance_theoretical_time_report,access_hr_attendance_theoretical_time_report,model_hr_attendance_theoretical_time_report,hr_attendance.group_hr_attendance_own_reader,1,0,0,0
access_wizard_theoretical_time,access_wizard_theoretical_time,model_wizard_theoretical_time,hr_attendance.group_hr_attendance_officer,1,1,1,1
access_recompute_theoretical_attendance,access_recompute_theoretical_attendance,model_recompute_theoretical_attendance,hr_attendance.group_hr_attendance_manager,1,1,1,1
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<li>Pedro M. Baeza.</li>
<li>David Vidal</li>
<li>Víctor Martínez</li>
<li>Juan José Seguí</li>
</ul>
</li>
<li>Pedro Gonzalez &lt;<a class="reference external" href="mailto:pedro.gonzalez&#64;pesol.es">pedro.gonzalez&#64;pesol.es</a>&gt;</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@

import datetime

from odoo.tests import common
from odoo.addons.base.tests.common import BaseCommon


class TestHrAttendanceReportTheoreticalTimeBase(common.TransactionCase):
class TestHrAttendanceReportTheoreticalTimeBase(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.HrLeave = cls.env["hr.leave"]
cls.HrHolidaysPublic = cls.env["hr.holidays.public"]
cls.HrLeaveType = cls.env["hr.leave.type"]
Expand Down Expand Up @@ -283,7 +273,7 @@ def test_wizard_theoretical_time(self):
)


class TestHrAttendanceReportTheoreticalTimeResource(common.TransactionCase):
class TestHrAttendanceReportTheoreticalTimeResource(BaseCommon):
@classmethod
def _define_calendar_2_weeks(cls, name, attendances, tz):
return cls.env["resource.calendar"].create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="view_mode">form</field>
<field
name="context"
>{'default_employee_ids': active_ids, 'employee_ids': active_ids, }</field>
>{'default_employee_ids': [id], 'employee_ids': [id], }</field>
<field name="target">new</field>
<field
name="groups_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
name="Select Employees"
action="wizard_theoretical_time_act_window"
parent="menu_hr_attendance_theoretical_root"
groups="hr_attendance.group_hr_attendance_user"
groups="hr_attendance.group_hr_attendance_officer"
sequence="25"
/>
</odoo>

0 comments on commit 4b37c66

Please sign in to comment.