Skip to content

Commit

Permalink
Merge pull request #3056 from ONE-F-M/fix-conflict
Browse files Browse the repository at this point in the history
Test production to Master
  • Loading branch information
mymi14s authored Jan 11, 2024
2 parents 0f7e11e + 2b205af commit 9d96449
Show file tree
Hide file tree
Showing 19 changed files with 23,104 additions and 3,292 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
port: 22
script: |
cd /home/frappe/frappe-bench/apps/one_fm # we move into our app's folder
git pull upstream staging # we pull any changes from git
# git pull upstream staging # we pull any changes from git
git pull
cd /home/frappe
pip3 install --upgrade frappe-bench
cd /home/frappe/frappe-bench
# bench setup requirements
bench migrate # sync database
Expand Down
3 changes: 3 additions & 0 deletions one_fm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
from frappe.automation.doctype.assignment_rule.assignment_rule import AssignmentRule
from one_fm.overrides.assignment_rule import do_assignment
from one_fm.overrides.goal import get_childrens


__version__ = '14.6.2'


StockController.make_batches = make_batches_with_supplier_batch_id
Interview.validate_overlap = validate_interview_overlap
PaymentEntry.add_party_gl_entries = add_party_gl_entries_
Expand Down
113 changes: 113 additions & 0 deletions one_fm/api/doc_methods/shift_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,119 @@ def update_request(shift_request, from_date, to_date):
shift_request_obj.db_set("status", 'Draft')
apply_workflow(shift_request_obj, "Update Request")

def _get_employee_from_user(user):
employee_docname = frappe.db.get_value("Employee", {"user_id": user})
return employee_docname if employee_docname else None


def get_manager(doctype,employee):
field = None
if doctype =="Project":
field = 'account_manager'
elif doctype =='Operations Site':
field = 'account_supervisor'
elif doctype =='Operations Shift':
field = 'supervisor'
if field:
values = frappe.get_all(doctype,{field:employee},['name'])
if values:
return [i.name for i in values]



@frappe.whitelist()
def fetch_employee_details(employee):
emp_data = frappe.get_all("Employee",{'name':employee},['employee_name','company','shift','site','project','default_shift','department'])
return emp_data[0] if emp_data else []

@frappe.whitelist()
def get_employees(doctype, txt, searchfield, start, page_len, filters):
"""
Return the full list of employees if current user has a HR role or Included in the Employee Master Table.
else, it returns the full list of employees assigned to the Operations shifts,sites or projects where this user is set
"""

is_master= False
default_user_roles = None
employee_master_roles = frappe.get_all("ONEFM Document Access Roles Detail",{'parent':"ONEFM General Setting",'parentfield':"employee_master_role"},['role'])
user_roles = frappe.get_roles(frappe.session.user) or []
default_user_roles = [i.role for i in employee_master_roles] if employee_master_roles else ['HR Manager',"HR User"]
#if user has any default hr role
if [role for role in user_roles if role in default_user_roles ]:
is_master = True
if is_master:
#If the user has not typed anything on the employee field
if not txt:
employees = frappe.db.sql("Select name,employee_name,employee_id from `tabEmployee` where status = 'Active' ")
return employees
else:
#If the user has typed anything on the employee field
employees = frappe.db.sql(f"Select name,employee_name,employee_id from `tabEmployee` where status = 'Active' and name like '%{txt}%' or employee_name like '%{txt}%' or employee_id like '%{txt}%' ")
return employees

else:
allowed_employees = []
user = frappe.session.user
if user!="Administrator":
employee_id = _get_employee_from_user(user)
if employee_id:
employee_base_query = f"""
SELECT name,employee_name,employee_id from `tabEmployee` where status = "Active"
"""
cond_str = ""
query = None
allowed_employees.append(employee_id)
#get all reports to
reports_to = frappe.get_all("Employee",{'reports_to':employee_id,'status':"Active"},'name')
if reports_to:
allowed_employees+=[i.name for i in reports_to]
#get all employees in project,shift and site
if allowed_employees:
cond_str = f" and name in {tuple(allowed_employees)}" if len(allowed_employees)>1 else f" and name = {allowed_employees[0]}"
if txt:
cond_str+=f" and (name like '%{txt}%' or employee_name like '%{txt}%' or employee_id like '%{txt}%') "
query=employee_base_query+cond_str
shifts = get_manager('Operations Shift',employee_id)
if shifts:
cond_str = f" and shift in {tuple(shifts)}" if len(shifts)>1 else f" and shift = {shifts[0]}"
if txt:
cond_str+=f" and (name like '%{txt}%' or employee_name like '%{txt}%' or employee_id like '%{txt}%') "
query += f""" UNION SELECT name,employee_name,employee_id from `tabEmployee` where status = "Active" {cond_str} """
sites = get_manager('Operations Site',employee_id)
if sites:
cond_str = f" and site in {tuple(sites)}" if len(sites)>1 else f" and site = {sites[0]}"
if txt:
cond_str+=f" and (name like '%{txt}%' or employee_name like '%{txt}%' or employee_id like '%{txt}%') "
query += f""" UNION SELECT name,employee_name,employee_id from `tabEmployee` where status = "Active" {cond_str} """
project = get_manager('Project',employee_id)
if project:
cond_str = f" and project in {tuple(project)}" if len(project)>1 else f" and project = {project[0]}"
if txt:
cond_str+=f" and (name like '%{txt}%' or employee_name like '%{txt}%' or employee_id like '%{txt}%') "
query += f""" UNION SELECT name,employee_name,employee_id from `tabEmployee` where status = "Active" {cond_str} """
#Check if employee is set in operations shift, operations site or project

return frappe.db.sql(query)


else:
return ()
else:
if not txt:
return frappe.db.sql("Select name,employee_name,employee_id from `tabEmployee` where status = 'Active' ")
else:
return frappe.db.sql("Select name,employee_name,employee_id from `tabEmployee` where status = 'Active' and name \
like '%{txt}%' or employee_name like '%{txt}%' \or employee_id like '%{txt}%' ")









@frappe.whitelist()
def get_operations_role(doctype, txt, searchfield, start, page_len, filters):
shift = filters.get('operations_shift')
Expand Down
19 changes: 19 additions & 0 deletions one_fm/change_log/v14/v14_6_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Version 14.6.3 Release Notes

### Features
- [Segregate the total attendance check in justification report by roster type](https://github.com/ONE-F-M/One-FM/pull/3038)
- [Attendance Check approval for shift and non-shift employees](https://github.com/ONE-F-M/One-FM/pull/3045)
- [Update on cancel shift request](https://github.com/ONE-F-M/One-FM/pull/3043)
- Remove FrappeDesk reference from the workspace

### Fixes
- [ONEFM General Settings not found error](https://github.com/ONE-F-M/One-FM/pull/3037)
- [Attendance Check approval issue due to Compensatory Leave Request](https://github.com/ONE-F-M/One-FM/pull/3035)
- [Interview Feedback average rating correction](https://github.com/ONE-F-M/One-FM/pull/3047)
- [Attendance request can't open](https://github.com/ONE-F-M/One-FM/pull/3028)
- [Google Export Data Issue](https://github.com/ONE-F-M/One-FM/pull/3039)

### Chores
- [Employee query is updated to be able to filter by employee id](https://github.com/ONE-F-M/One-FM/pull/3031)
- [Permission concerning edit access to employee status field](https://github.com/ONE-F-M/One-FM/pull/3044)
- [Auto attendance creates for active employees only](https://github.com/ONE-F-M/One-FM/pull/3030)
Loading

0 comments on commit 9d96449

Please sign in to comment.