From 8386773a5b431accc484b7a0e2b27ed04cc9735b Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Mon, 6 Nov 2017 15:12:08 +0100 Subject: [PATCH] [IMP] resource: define a conversion factor hour to day on working calendar Using a working calendar, you might want to know how much hour correspond a work day. This depends of you working calendar. This might be usefull to compute leave duration (half a day is not 8 hours, but 4). The hours_per_day field is not computed as the average of working hour of all work day of calendar to allow customization. By default, it is 8, as the default attendances are the one from the 40h/week calendar. A constant is also available to handle case where resource calendar is not available. --- addons/hr_holidays/models/hr_leave.py | 5 ++--- addons/resource/data/resource_data.xml | 2 ++ addons/resource/models/resource.py | 22 +++++++++++++++++++++- addons/resource/views/resource_views.xml | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 2d72154e76c..6f4a96b800b 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -12,11 +12,10 @@ from odoo.exceptions import UserError, AccessError, ValidationError from odoo.tools import float_compare from odoo.tools.translate import _ +from odoo.addons.resource.models.resource import HOURS_PER_DAY + _logger = logging.getLogger(__name__) - -HOURS_PER_DAY = 8 - class HolidaysRequest(models.Model): _name = "hr.leave" _description = "Leave" diff --git a/addons/resource/data/resource_data.xml b/addons/resource/data/resource_data.xml index bcfd2c91446..84d0e86f46e 100644 --- a/addons/resource/data/resource_data.xml +++ b/addons/resource/data/resource_data.xml @@ -24,6 +24,7 @@ Standard 35 Hours/Week + 7.0 Standard 38 Hours/Week + 7.6 attendance.hour_to: + raise ValidationError(_("The start-hour must be lower than end-hour.")) + class ResourceResource(models.Model): _name = "resource.resource" diff --git a/addons/resource/views/resource_views.xml b/addons/resource/views/resource_views.xml index b97129d6576..c7c2855b6bb 100644 --- a/addons/resource/views/resource_views.xml +++ b/addons/resource/views/resource_views.xml @@ -249,6 +249,7 @@ +