mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of hr_holidays_partial.
This commit is contained in:
1
hr_holidays_partial/__init__.py
Normal file
1
hr_holidays_partial/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
18
hr_holidays_partial/__manifest__.py
Normal file
18
hr_holidays_partial/__manifest__.py
Normal 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,
|
||||||
|
}
|
||||||
1
hr_holidays_partial/models/__init__.py
Normal file
1
hr_holidays_partial/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import hr_holiday
|
||||||
30
hr_holidays_partial/models/hr_holiday.py
Normal file
30
hr_holidays_partial/models/hr_holiday.py
Normal 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
|
||||||
14
hr_holidays_partial/views/hr_holidays_views.xml
Normal file
14
hr_holidays_partial/views/hr_holidays_views.xml
Normal 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>
|
||||||
Reference in New Issue
Block a user