[IMP] hr_holidays: handle UoM in resource calendar
In a company, there might be several contract types, e.g.: - 38 Hours/Week, 5 Days/Week - 45 Hours/Week, 5 Days/Week - 24 Hours/Week, 2 Days/Week (work on week-end only) Therefore, it is necessary to be able to define the average number of hours per day on a resource calendar.
This commit is contained in:
@@ -293,7 +293,7 @@ class hr_holidays(osv.osv):
|
||||
resource = resource_obj.browse(cr, uid, resource_ids, context=context)
|
||||
if resource and resource.calendar_id:
|
||||
hours = resource.calendar_id.get_working_hours(from_dt, to_dt, resource_id=resource.id, compute_leaves=True)
|
||||
uom_hour = model_data_obj.xmlid_to_object(cr, uid, 'product.product_uom_hour')
|
||||
uom_hour = resource.calendar_id.uom_id
|
||||
uom_day = model_data_obj.xmlid_to_object(cr, uid, 'product.product_uom_day')
|
||||
if uom_hour and uom_day:
|
||||
return uom_obj._compute_qty_obj(cr, uid, uom_hour, hours[0], uom_day, context=context)
|
||||
@@ -548,6 +548,22 @@ class hr_holidays(osv.osv):
|
||||
return res
|
||||
|
||||
|
||||
class resource_calendar(osv.osv):
|
||||
_inherit = "resource.calendar"
|
||||
_columns = {
|
||||
'uom_id': fields.many2one("product.uom", "Hours per Day", required=True,
|
||||
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"""),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'uom_id': lambda self, cr, uid, c: self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'product.product_uom_hour')
|
||||
}
|
||||
|
||||
|
||||
class resource_calendar_leaves(osv.osv):
|
||||
_inherit = "resource.calendar.leaves"
|
||||
_description = "Leave Detail"
|
||||
|
||||
@@ -552,6 +552,18 @@
|
||||
<menuitem id="menu_hr_holidays_configuration" name="Configuration" parent="menu_hr_holidays_root"
|
||||
sequence="100" groups="base.group_hr_manager" action="open_view_holiday_status"/>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
@@ -92,6 +92,11 @@ msgstr ""
|
||||
msgid "Absence by Today"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.hr_department_view_kanban
|
||||
msgid "Absent Employee(s), Whose leaves request are either confirmed or validated on today"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.actions.act_window,name:hr_holidays.hr_employee_action_from_department
|
||||
msgid "Absent Employees"
|
||||
@@ -180,6 +185,11 @@ msgstr ""
|
||||
msgid "Allocation to Approve"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.view_hr_holidays_filter
|
||||
msgid "Allocations"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model.fields,field_description:hr_holidays.field_hr_holidays_status_limit
|
||||
msgid "Allow to Override Limit"
|
||||
@@ -225,6 +235,15 @@ msgstr ""
|
||||
msgid "Assign Leaves"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model.fields,help:hr_holidays.field_resource_calendar_uom_id
|
||||
msgid "Average hours of work per day.\n"
|
||||
" It is used in an employee leave request to compute the number of days consumed based on the resource calendar.\n"
|
||||
" It can be used to handle various contract types, e.g.:\n"
|
||||
" - 38 Hours/Week, 5 Days/Week: 1 Day = 7.6 Hours\n"
|
||||
" - 45 Hours/Week, 5 Days/Week: 1 Day = 9.0 Hours"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: selection:hr.holidays.status,color_name:0
|
||||
msgid "Black"
|
||||
@@ -357,6 +376,11 @@ msgstr ""
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.view_hr_holidays_filter
|
||||
msgid "Current"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model.fields,field_description:hr_holidays.field_hr_employee_current_leave_state
|
||||
msgid "Current Leave Status"
|
||||
@@ -518,6 +542,16 @@ msgstr ""
|
||||
msgid "HR Leaves Summary Report By Employee"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model.fields,field_description:hr_holidays.field_resource_calendar_uom_id
|
||||
msgid "Hours per Day"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model,name:hr_holidays.model_hr_department
|
||||
msgid "Hr Department"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model.fields,field_description:hr_holidays.field_hr_holidays_id
|
||||
#: model:ir.model.fields,field_description:hr_holidays.field_hr_holidays_remaining_leaves_user_id
|
||||
@@ -667,6 +701,7 @@ msgstr ""
|
||||
#: model:ir.ui.menu,name:hr_holidays.menu_open_department_leave_approve
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.hr_department_view_kanban
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.view_employee_form_leave_inherit
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.view_hr_holidays_filter
|
||||
msgid "Leaves"
|
||||
msgstr ""
|
||||
|
||||
@@ -1046,6 +1081,11 @@ msgstr ""
|
||||
msgid "Reset to Draft"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.model,name:hr_holidays.model_resource_calendar
|
||||
msgid "Resource Calendar"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_holidays
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.view_hr_holidays_filter
|
||||
msgid "Search Leave"
|
||||
@@ -1347,4 +1387,3 @@ msgstr ""
|
||||
#: model:ir.ui.view,arch_db:hr_holidays.report_holidayssummary
|
||||
msgid "to"
|
||||
msgstr ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user