diff --git a/hr_fix_holiday_hours_display_compute/.gitignore b/hr_fix_holiday_hours_display_compute/.gitignore new file mode 100644 index 0000000..6da5887 --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/.gitignore @@ -0,0 +1,2 @@ +*.*~ +*pyc diff --git a/hr_fix_holiday_hours_display_compute/README.rst b/hr_fix_holiday_hours_display_compute/README.rst new file mode 100644 index 0000000..43ee26b --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/README.rst @@ -0,0 +1,43 @@ +==================================== +hr_fix_holiday_hours_display_compute +==================================== + +Fix commit https://github.com/odoo/odoo/commit/6f587ab563a98becf6a8a38beaa1615b8834a7e9 + +Installation +============ + +Use Odoo normal module installation procedure to install +``hr_fix_holiday_hours_display_compute``. + +Known issues / Roadmap +====================== + +None yet. +Bug Tracker +=========== + +Bugs are tracked on `our issues website `_. In case of +trouble, please check there if your issue has already been +reported. If you spotted it first, help us smashing it by providing a +detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Stéphan Sainléger + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- + +This module is maintained by Elabore. diff --git a/hr_fix_holiday_hours_display_compute/__init__.py b/hr_fix_holiday_hours_display_compute/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/hr_fix_holiday_hours_display_compute/__manifest__.py b/hr_fix_holiday_hours_display_compute/__manifest__.py new file mode 100644 index 0000000..458ea3e --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/__manifest__.py @@ -0,0 +1,41 @@ +# Copyright 2022 Stéphan Sainléger (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "hr_fix_holiday_hours_display_compute", + "version": "12.0.1.0.0", + "author": "Elabore", + "website": "https://elabore.coop", + "maintainer": "Stéphan Sainléger", + "license": "AGPL-3", + "category": "Tools", + "summary": "Fix commit https://github.com/odoo/odoo/commit/6f587ab563a98becf6a8a38beaa1615b8834a7e9", + "description": """ + :image: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +""", + # any module necessary for this one to work correctly + "depends": [ + "base", + "hr_holidays" + ], + "qweb": [ + # "static/src/xml/*.xml", + ], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} \ No newline at end of file diff --git a/hr_fix_holiday_hours_display_compute/models/__init__.py b/hr_fix_holiday_hours_display_compute/models/__init__.py new file mode 100644 index 0000000..91cd9cc --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/models/__init__.py @@ -0,0 +1 @@ +from . import hr_leave \ No newline at end of file diff --git a/hr_fix_holiday_hours_display_compute/models/hr_leave.py b/hr_fix_holiday_hours_display_compute/models/hr_leave.py new file mode 100644 index 0000000..6cfad1b --- /dev/null +++ b/hr_fix_holiday_hours_display_compute/models/hr_leave.py @@ -0,0 +1,17 @@ +from odoo import api, fields, models +from odoo.addons.resource.models.resource import float_to_time, HOURS_PER_DAY + + +class HolidaysRequest(models.Model): + _inherit = "hr.leave" + + @api.multi + @api.depends('number_of_days') + def _compute_number_of_hours_display(self): + for holiday in self: + calendar = holiday.employee_id.resource_calendar_id or self.env.user.company_id.resource_calendar_id + if holiday.date_from and holiday.date_to: + number_of_hours = calendar.get_work_hours_count(holiday.date_from, holiday.date_to) + holiday.number_of_hours_display = number_of_hours or (holiday.number_of_days * HOURS_PER_DAY) + else: + holiday.number_of_hours_display = 0 \ No newline at end of file