Initial commit of hr_holidays_partial.

This commit is contained in:
Kristen Marie Kulha
2018-08-24 18:28:39 -07:00
parent 50da6a7bbb
commit 5a8bf80b93
5 changed files with 64 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,18 @@
{
'name': 'HR Holidays Partial',
'author': 'Hibou Corp. <hello@hibou.io>',
'version': '11.0.0.0.0',
'category': 'Human Resources',
'sequence': 95,
'summary': 'Partial day leave requests displau hours',
'description': """
Create and display leave requests in hours for partial days.
""",
'website': 'https://hibou.io/',
'depends': ['hr_holidays'],
'data': [
'views/hr_holidays_views.xml',
],
'installable': True,
'application': False,
}

View File

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

View File

@@ -0,0 +1,30 @@
from odoo import api, fields, models
from math import ceil
from odoo.addons.hr_holidays.models.hr_holidays import HOURS_PER_DAY
class HRHoliday(models.Model):
_inherit = 'hr.holidays'
days_in_hours = fields.Float(string="Hours", compute='_get_days_in_hours')
def _get_number_of_days(self, date_from, date_to, employee_id):
from_dt = fields.Datetime.from_string(date_from)
to_dt = fields.Datetime.from_string(date_to)
if employee_id:
employee = self.env['hr.employee'].browse(employee_id)
num_days = employee.get_work_days_count(from_dt, to_dt)
if num_days == 0:
time_delta = to_dt - from_dt
hours = (time_delta.seconds / 3600)
return hours / HOURS_PER_DAY
else:
return employee.get_work_days_count(from_dt, to_dt)
time_delta = to_dt - from_dt
return ceil(time_delta.days + float(time_delta.seconds) / 86400)
@api.depends('number_of_days_temp')
def _get_days_in_hours(self):
self.days_in_hours = self.number_of_days_temp * 8

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="hr_holidays_edit_holiday_new_inherit" model="ir.ui.view">
<field name="name">hr.holidays.edit.holiday.new.inherit</field>
<field name="model">hr.holidays</field>
<field name="priority">20</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_new"/>
<field name="arch" type="xml">
<xpath expr="//group/group[1]" position="inside">
<field name="days_in_hours" />
</xpath>
</field>
</record>
</odoo>