Skip to content

Commit 686d686

Browse files
committed
fix: sqlite support
Basically involves setting the correct types here. Some date fields had datetime values set, which MariaDB "accepts", but won't work with the way we have setup some types for SQLite. Signed-off-by: Akhil Narang <[email protected]>
1 parent 70cc92f commit 686d686

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

helpdesk/helpdesk/doctype/hd_service_level_agreement/hd_service_level_agreement.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def set_resolution_date(self, doc: Document):
205205
doc.resolution_date = None
206206
doc.resolution_time = None
207207
return
208-
doc.resolution_date = now_datetime()
208+
doc.resolution_date = frappe.utils.nowdate()
209209
start_at = doc.service_level_agreement_creation
210210
end_at = doc.resolution_date
211211
time_took = self.calc_elapsed_time(start_at, end_at)
@@ -355,11 +355,21 @@ def calc_time(
355355
current_datetime, current_date
356356
)
357357
start_time = max(
358-
current_workday_doc.start_time.total_seconds(), current_time_in_seconds
358+
timedelta(
359+
hours=current_workday_doc.start_time.hour,
360+
minutes=current_workday_doc.start_time.minute,
361+
seconds=current_workday_doc.start_time.second,
362+
).total_seconds(),
363+
current_time_in_seconds,
359364
)
360365
till_start_time = max(start_time - current_time_in_seconds, 0)
361366
end_time = max(
362-
current_workday_doc.end_time.total_seconds(), current_time_in_seconds
367+
timedelta(
368+
hours=current_workday_doc.end_time.hour,
369+
minutes=current_workday_doc.end_time.minute,
370+
seconds=current_workday_doc.end_time.second,
371+
).total_seconds(),
372+
current_time_in_seconds,
363373
)
364374
time_left = max(end_time - start_time, 0)
365375
if not time_left:

helpdesk/setup/install.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ def add_default_sla():
132132
def add_default_holiday_list():
133133
if frappe.db.exists("HD Service Holiday List", "Default"):
134134
return
135+
from datetime import date
136+
137+
year = date.today().year
135138
frappe.get_doc(
136139
{
137140
"doctype": "HD Service Holiday List",
138141
"holiday_list_name": "Default",
139-
"from_date": datetime.strptime(f"Jan 1 {datetime.now().year}", "%b %d %Y"),
140-
"to_date": datetime.strptime(
141-
f"Jan 1 {datetime.now().year + 1}", "%b %d %Y"
142-
),
142+
"from_date": date(year, 1, 1),
143+
"to_date": date(year + 1, 1, 1),
143144
}
144145
).insert()
145146

0 commit comments

Comments
 (0)