1 Commits

Author SHA1 Message Date
Stéphan Sainléger
a990de3b3d [NEW] hr_fix_holiday_hours_display_compute: create add-on 2022-12-20 18:21:08 +01:00
6 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -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 <https://github.com/elabore-coop/hr-tools/issues>`_. 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.

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1 @@
from . import hr_leave

View File

@@ -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