Merge pull request #5775 from expsa/bakry_hr

Bakry hr
This commit is contained in:
bakry 2025-12-21 17:03:52 +03:00 committed by GitHub
commit 665d6e8c8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -142,10 +142,11 @@ class Employee(models.Model):
def _compute_leave_status(self): def _compute_leave_status(self):
# Used SUPERUSER_ID to forcefully get status of other user's leave, to bypass record rule # Used SUPERUSER_ID to forcefully get status of other user's leave, to bypass record rule
today_now = fields.Datetime.to_datetime(fields.Date.today())
holidays = self.env['hr.holidays'].sudo().search([ holidays = self.env['hr.holidays'].sudo().search([
('employee_id', 'in', self.ids), ('employee_id', 'in', self.ids),
('date_from', '<=', fields.Datetime.now()), ('date_from', '<=', today_now),
('date_to', '>=', fields.Datetime.now()), ('date_to', '>=', today_now),
('type', '=', 'remove'), ('type', '=', 'remove'),
('state', 'not in', ('cancel', 'refuse')) ('state', 'not in', ('cancel', 'refuse'))
]) ])

View File

@ -1622,20 +1622,21 @@ class HRHolidays(models.Model):
"""chick a holiday take balance with years balance""" """chick a holiday take balance with years balance"""
for item in self: for item in self:
holiday_days = item.number_of_days_temp holiday_days = item.number_of_days_temp
holiday_type = item.holiday_status_id.leave_type
employee_balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id), employee_balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
('holiday_status_id', '=', item.holiday_status_id.id), ('holiday_status_id', '=', item.holiday_status_id.id),
('type', '=', 'add'), ('type', '=', 'add'),
('check_allocation_view', '=', 'balance')], ('check_allocation_view', '=', 'balance')],
order='id desc', limit=1) order='id desc', limit=1)
leave_type = ['exam', 'marriage','parental','emergency','sick'] leave_type = ['exam', 'marriage','parental','emergency','sick']
if item.holiday_status_id.leave_type in leave_type: if holiday_type in leave_type:
cron_run_date = item.employee_id.first_hiring_date cron_run_date = item.employee_id.first_hiring_date
holi_date_from = fields.Date.from_string(item.date_from) holi_date_from = fields.Date.from_string(item.date_from)
holi_date_to = fields.Date.from_string(item.date_to) holi_date_to = fields.Date.from_string(item.date_to)
if employee_balance.holiday_ids: if employee_balance.holiday_ids:
cron_run_date = employee_balance.holiday_ids[-1].cron_run_date cron_run_date = employee_balance.holiday_ids[-1].cron_run_date
if cron_run_date > holi_date_to: if (holiday_type=='sick' and cron_run_date > holi_date_to) or (cron_run_date.year > holi_date_to.year):
holiday_days = 0 holiday_days = 0
if holi_date_to >= cron_run_date > holi_date_from: if holi_date_to >= cron_run_date > holi_date_from:
holiday_days = (holi_date_to - cron_run_date).days+1 holiday_days = (holi_date_to - cron_run_date).days+1

View File

@ -9,6 +9,7 @@ from .helper import httpHelper, is_valid_port, is_valid_ip, ParsedRequest
class SystemAttendance(models.Model): class SystemAttendance(models.Model):
_name = 'finger.system_attendance' _name = 'finger.system_attendance'
_order = 'punch_time DESC'
punch_state = fields.Char("Punch state", readonly=True) punch_state = fields.Char("Punch state", readonly=True)
area_alias = fields.Char("Area", readonly=True) area_alias = fields.Char("Area", readonly=True)