diff --git a/hr_attendance_overtime_hours/__manifest__.py b/hr_attendance_overtime_hours/__manifest__.py index 48b3c6c7..3d0f217a 100644 --- a/hr_attendance_overtime_hours/__manifest__.py +++ b/hr_attendance_overtime_hours/__manifest__.py @@ -4,7 +4,7 @@ Show planned and worked hours in overtime view. """, "author": "Mint System GmbH, Odoo Community Association (OCA)", - "website": "https://www.mint-system.ch", + "website": "https://github.com/OCA/hr-attendance", "category": "Human Resources", "version": "15.0.1.0.0", "license": "AGPL-3", diff --git a/hr_attendance_overtime_hours/models/__init__.py b/hr_attendance_overtime_hours/models/__init__.py index 31960076..0cc4304b 100644 --- a/hr_attendance_overtime_hours/models/__init__.py +++ b/hr_attendance_overtime_hours/models/__init__.py @@ -1 +1 @@ -from . import hr_attendance_overtime \ No newline at end of file +from . import hr_attendance_overtime diff --git a/hr_attendance_overtime_hours/models/hr_attendance_overtime.py b/hr_attendance_overtime_hours/models/hr_attendance_overtime.py index 46e993bb..f6403754 100644 --- a/hr_attendance_overtime_hours/models/hr_attendance_overtime.py +++ b/hr_attendance_overtime_hours/models/hr_attendance_overtime.py @@ -1,32 +1,43 @@ -from odoo import models, fields, api -from datetime import datetime, time import logging +from datetime import datetime, time + +from odoo import api, fields, models + _logger = logging.getLogger(__name__) class HrAttendanceOvertime(models.Model): - _inherit = 'hr.attendance.overtime' - - planned_hours = fields.Float(compute='_compute_planned_hours', store=True, readonly=True) - worked_hours = fields.Float(compute='_compute_worked_hours', store=True, readonly=True) + _inherit = "hr.attendance.overtime" + + planned_hours = fields.Float( + compute="_compute_planned_hours", store=True, readonly=True + ) + worked_hours = fields.Float( + compute="_compute_worked_hours", store=True, readonly=True + ) - @api.depends('date') + @api.depends("date") def _compute_planned_hours(self): for overtime in self: # Get work hours from calendar - planned_hours = overtime.employee_id.resource_calendar_id.get_work_hours_count( - datetime.combine(overtime.date, time.min), - datetime.combine(overtime.date, time.max), - True) + planned_hours = ( + overtime.employee_id.resource_calendar_id.get_work_hours_count( + datetime.combine(overtime.date, time.min), + datetime.combine(overtime.date, time.max), + True, + ) + ) overtime.planned_hours = planned_hours - @api.depends('duration') + @api.depends("duration") def _compute_worked_hours(self): for overtime in self: # Get sum of attendance entries - attendance_ids = self.env['hr.attendance'].search([ - ('employee_id', '=', overtime.employee_id.id), - ('check_in', '>=', datetime.combine(overtime.date, time.min)), - ('check_out', '<=', datetime.combine(overtime.date, time.max)), - ]) - overtime.worked_hours = sum(attendance_ids.mapped('worked_hours')) \ No newline at end of file + attendance_ids = self.env["hr.attendance"].search( + [ + ("employee_id", "=", overtime.employee_id.id), + ("check_in", ">=", datetime.combine(overtime.date, time.min)), + ("check_out", "<=", datetime.combine(overtime.date, time.max)), + ] + ) + overtime.worked_hours = sum(attendance_ids.mapped("worked_hours")) diff --git a/hr_attendance_overtime_hours/pyproject.toml b/hr_attendance_overtime_hours/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/hr_attendance_overtime_hours/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_attendance_overtime_hours/views/hr_attendance_overtime.xml b/hr_attendance_overtime_hours/views/hr_attendance_overtime.xml index 3fa31523..76bd53b4 100644 --- a/hr_attendance_overtime_hours/views/hr_attendance_overtime.xml +++ b/hr_attendance_overtime_hours/views/hr_attendance_overtime.xml @@ -1,14 +1,16 @@ - + - hr_attendance_overtime_hours.view_attendance_overtime_tree + hr_attendance_overtime_hours.view_attendance_overtime_tree hr.attendance.overtime - - + +