From 617b7a2f39990b40714794d578d7e08c4be11667 Mon Sep 17 00:00:00 2001 From: blackbelts <74664702+eslamtalaat74@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:49:24 +0300 Subject: [PATCH] date req --- .../models/hr_official_mission.py | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/odex25_hr/exp_official_mission/models/hr_official_mission.py b/odex25_hr/exp_official_mission/models/hr_official_mission.py index 4d9c3d8fd..6dd69a884 100644 --- a/odex25_hr/exp_official_mission/models/hr_official_mission.py +++ b/odex25_hr/exp_official_mission/models/hr_official_mission.py @@ -408,6 +408,7 @@ class HrOfficialMission(models.Model): else: line.hours = (line.hour_to - line.hour_from) line.total_hours = line.hours * line.days + print("11111111111") if item.mission_type.related_with_financial is True: if item.mission_type.type_of_payment == 'fixed': if item.mission_type.hour_price: @@ -1365,7 +1366,17 @@ class HrOfficialMissionEmployee(models.Model): weekend_names = [d.name.lower() for d in weekend_days] date_range = [d for d in date_range if d.strftime('%A').lower() not in weekend_names] - item.days = len(date_range) + + if not item.official_mission_id.table_ids: + + item.days = len(date_range) + else: + + unique_dates = set(item.official_mission_id.table_ids.mapped('date')) + item.days = len(unique_dates) + print(item.days) + print(item.days) + # item.days = len(date_range) else: raise exceptions.Warning(_('Date Form Must Be Less than Date To')) else: @@ -1386,7 +1397,18 @@ class HrOfficialMissionEmployee(models.Model): weekend_names = [d.name.lower() for d in weekend_days] date_range = [d for d in date_range if d.strftime('%A').lower() not in weekend_names] - item.days = len(date_range) + print("pppppppp00") + print(date_range) + if not item.official_mission_id.table_ids: + print("55555555556") + item.days = len(date_range) + else: + print("kkkffld") + unique_dates = set(item.official_mission_id.table_ids.mapped('date')) + item.days = len(unique_dates) + print(item.days) + print(item.days) + else: raise exceptions.Warning(_('Date Form Must Be Less than Date To')) @@ -1405,6 +1427,8 @@ class HrOfficialMissionEmployee(models.Model): else: item.hours = (item.hour_to - item.hour_from) item.total_hours = item.hours * item.days + print("22222222222") + else: item.hour_from = item.official_mission_id.hour_from item.hour_to = item.official_mission_id.hour_to @@ -1416,6 +1440,7 @@ class HrOfficialMissionEmployee(models.Model): item.hours = (item.hour_to - item.hour_from) item.total_hours = item.hours * item.days + # compute day_price , hour_price and amount @api.onchange('hour_from', 'hour_to', 'hours', 'date_from', 'date_to', 'days', 'employee_id', 'day_price',