fix get attendance biotime

This commit is contained in:
mohammed-alkhazrji 2025-10-06 19:23:30 +03:00
parent de456fce5c
commit f5f140a9e7
2 changed files with 38 additions and 5 deletions

View File

@ -366,7 +366,12 @@ class BiotimeAPI(models.Model):
if not self.token:
self.refresh()
_, _, _, _, _, _, _, _, _, transctionsUrl = self._calc_urls()
res = httpHelper.fetch_empl_transctions({}, self.token, transctionsUrl)
# 10 (Oct month 2025)
start_date = "2025-10-01 00:00:00"
url_with_filter = transctionsUrl + "?start_time=" + start_date
res = httpHelper.fetch_empl_transctions({}, self.token, url_with_filter)
if not self.loaded_employees:
self.sync_employees()
@ -377,7 +382,7 @@ class BiotimeAPI(models.Model):
self.create_attendance(da.data)
while da.next:
res = httpHelper.fetch_empl_transctions(
{}, self.token, transctionsUrl + "?page=" + str(next))
{}, self.token, transctionsUrl + "?start_time=" + start_date + "&page=" + str(next))
if res.status_code == 200:
da = ParsedRequest(res.content)
self.create_attendance(da.data)
@ -389,6 +394,34 @@ class BiotimeAPI(models.Model):
except Exception as e:
ValidationError(str(e))
# def sync_attenence(self):
# self.login()
# if not self.token:
# self.refresh()
# _, _, _, _, _, _, _, _, _, transctionsUrl = self._calc_urls()
# res = httpHelper.fetch_empl_transctions({}, self.token, transctionsUrl)
# if not self.loaded_employees:
# self.sync_employees()
#
# try:
# if res.status_code == 200:
# da = ParsedRequest(res.content)
# next = 2
# self.create_attendance(da.data)
# while da.next:
# res = httpHelper.fetch_empl_transctions(
# {}, self.token, transctionsUrl + "?page=" + str(next))
# if res.status_code == 200:
# da = ParsedRequest(res.content)
# self.create_attendance(da.data)
# else:
# da.next = None
# next = next + 1
# else:
# self.errorHandler(res)
# except Exception as e:
# ValidationError(str(e))
def create_termainl(self, termainls):
TerminalsModel = self.env['finger.terminal']
@ -538,7 +571,7 @@ class BiotimeAPI(models.Model):
_, _, _, _, _, _, _, _, _, transctionsUrl = self._calc_urls()
for r in self:
for xm in r.employee_ids:
# url = "{}?start_time={}&end_time={}&emp_code={}".format(transctionsUrl,yesterday,now, xm.code )
url = "{}?punch_time={}&punch_time={}&emp_code={}".format(transctionsUrl, yesterday, now, xm.code)
url = "{}?start_time={}&end_time={}&emp_code={}".format(transctionsUrl,yesterday,now, xm.code )
# url = "{}?punch_time={}&punch_time={}&emp_code={}".format(transctionsUrl, yesterday, now, xm.code)
# print('################################# New Employee',url)
r.sync_employee_attenence(url)

View File

@ -1,7 +1,7 @@
id,name,model_id:id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_finger_system_attendance,finger_system_attendance,to_attendance_system.model_finger_system_attendance,,1,1,1,0
access_finger_biotime_api,finger_biotime_api,to_attendance_system.model_finger_biotime_api,,1,1,1,0
access_finger_employee_department,finger_employee_department,to_attendance_system.model_finger_biotime_api,,1,1,1,0
access_finger_employee_department,finger_employee_department,to_attendance_system.model_finger_employee_department,,1,1,1,0
access_finger_area,finger_area,to_attendance_system.model_finger_area,,1,1,1,0
access_finger_employee_position,finger_employee_position,to_attendance_system.model_finger_employee_position,,1,1,1,0
access_finger_employee_employee,finger_employee_employee,to_attendance_system.model_finger_employee_employee,,1,1,1,0

1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
2 access_finger_system_attendance finger_system_attendance to_attendance_system.model_finger_system_attendance 1 1 1 0
3 access_finger_biotime_api finger_biotime_api to_attendance_system.model_finger_biotime_api 1 1 1 0
4 access_finger_employee_department finger_employee_department to_attendance_system.model_finger_biotime_api to_attendance_system.model_finger_employee_department 1 1 1 0
5 access_finger_area finger_area to_attendance_system.model_finger_area 1 1 1 0
6 access_finger_employee_position finger_employee_position to_attendance_system.model_finger_employee_position 1 1 1 0
7 access_finger_employee_employee finger_employee_employee to_attendance_system.model_finger_employee_employee 1 1 1 0