[REF] hr_holidays: improve resource integration and remove product strange dependency
This commit is contained in:
@@ -24,7 +24,7 @@ You can keep track of leaves in different ways by following reports:
|
||||
|
||||
A synchronization with an internal agenda (Meetings of the CRM module) is also possible in order to automatically create a meeting when a leave request is accepted by setting up a type of meeting in Leave Type.
|
||||
""",
|
||||
'depends': ['hr', 'calendar', 'resource', 'product', 'report'],
|
||||
'depends': ['hr', 'calendar', 'resource', 'report'],
|
||||
'data': [
|
||||
'data/report_paperformat.xml',
|
||||
'data/hr_holidays_data.xml',
|
||||
|
||||
@@ -186,8 +186,10 @@ class Holidays(models.Model):
|
||||
manager_id = fields.Many2one('hr.employee', string='First Approval', readonly=True, copy=False,
|
||||
help='This area is automatically filled by the user who validate the leave')
|
||||
notes = fields.Text('Reasons', readonly=True, states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]})
|
||||
number_of_days_temp = fields.Float('Allocation', readonly=True, copy=False,
|
||||
states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]})
|
||||
number_of_days_temp = fields.Float(
|
||||
'Allocation', copy=False, readonly=True,
|
||||
states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]},
|
||||
help='Number of days of the leave request according to your working schedule.')
|
||||
number_of_days = fields.Float('Number of Days', compute='_compute_number_of_days', store=True, track_visibility='onchange')
|
||||
meeting_id = fields.Many2one('calendar.event', string='Meeting')
|
||||
type = fields.Selection([
|
||||
@@ -283,13 +285,7 @@ class Holidays(models.Model):
|
||||
|
||||
if employee_id:
|
||||
employee = self.env['hr.employee'].browse(employee_id)
|
||||
resource = employee.resource_id
|
||||
if resource and resource.calendar_id:
|
||||
hours = resource.calendar_id.get_work_hours_count(from_dt, to_dt, resource_id=resource.id, compute_leaves=True)
|
||||
uom_hour = resource.calendar_id.uom_id
|
||||
uom_day = self.env.ref('product.product_uom_day')
|
||||
if uom_hour and uom_day:
|
||||
return uom_hour._compute_quantity(hours, uom_day)
|
||||
return employee.get_work_days_count(from_dt, to_dt)
|
||||
|
||||
time_delta = to_dt - from_dt
|
||||
return math.ceil(time_delta.days + float(time_delta.seconds) / 86400)
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Calendar(models.Model):
|
||||
|
||||
_inherit = "resource.calendar"
|
||||
|
||||
uom_id = fields.Many2one("product.uom", string="Hours per Day", required=True,
|
||||
default=lambda self: self.env.ref('product.product_uom_hour'),
|
||||
help="""Average hours of work per day.
|
||||
It is used in an employee leave request to compute the number of days consumed based on the resource calendar.
|
||||
It can be used to handle various contract types, e.g.:
|
||||
- 38 Hours/Week, 5 Days/Week: 1 Day = 7.6 Hours
|
||||
- 45 Hours/Week, 5 Days/Week: 1 Day = 9.0 Hours""")
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class CalendarLeaves(models.Model):
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<odoo>
|
||||
<!-- UoM on resource calendar -->
|
||||
<record id="resource_calendar_form_inherit" model="ir.ui.view">
|
||||
<field name="name">resource.calendar.form.inherit</field>
|
||||
<field name="model">resource.calendar</field>
|
||||
<field name="inherit_id" ref="resource.resource_calendar_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Holiday on resource leave -->
|
||||
<record id="resource_calendar_leave_form_inherit" model="ir.ui.view">
|
||||
<field name="name">resource.calendar.leaves.form.inherit</field>
|
||||
@@ -23,5 +11,4 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user