[IMP]hr_employee_stats_sheet:add dependecie to hr_employee_calendar_planning and identifies the planning using by a employee during a time period
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m30s
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m30s
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import logging
|
||||
import pytz
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from datetime import timedelta
|
||||
from pytz import utc
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class HrEmployeeStats(models.Model):
|
||||
@@ -88,7 +87,7 @@ class HrEmployeeStats(models.Model):
|
||||
total_planned_hours = 0
|
||||
if self.employee_id and self.date and not self.is_public_holiday:
|
||||
dayofweek = int(self.date.strftime("%u")) - 1
|
||||
calendar_id = self.employee_id.resource_calendar_id
|
||||
calendar_id = self.employee_id._get_calendar_in_progress_during_a_time_period(self.date,self.date)
|
||||
week_number = self.date.isocalendar()[1] % 2
|
||||
if calendar_id.two_weeks_calendar:
|
||||
hours = calendar_id.attendance_ids.search(
|
||||
@@ -193,6 +192,10 @@ class HrEmployeeStats(models.Model):
|
||||
)
|
||||
if not public_holidays:
|
||||
return False
|
||||
if len(public_holidays) > 1:
|
||||
raise UserError(
|
||||
_("Several holidays have been found ont he date '%s'. Please correct the anomaly before continuing.") % self.date
|
||||
)
|
||||
ph = public_holidays[0]
|
||||
# Convert public holiday to the employee timezone
|
||||
ph_datetime_from_tz = self._convert_to_employee_tz(ph.date_from)
|
||||
|
||||
Reference in New Issue
Block a user