OpenHRMS
OpenHRMS copied to clipboard
Error when running dashboard
http://localhost:8069/web?debug#menu_id=313&action=446
Error: Odoo Server Error
Traceback (most recent call last): File "/c/dvlp/odoo/odoo/http.py", line 651, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/c/dvlp/odoo/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/c/dvlp/odoo/odoo/tools/pycompat.py", line 87, in reraise raise value File "/c/dvlp/odoo/odoo/http.py", line 693, in dispatch result = self._call_function(**self.params) File "/c/dvlp/odoo/odoo/http.py", line 342, in _call_function return checked_call(self.db, *args, **kwargs) File "/c/dvlp/odoo/odoo/service/model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "/c/dvlp/odoo/odoo/http.py", line 335, in checked_call result = self.endpoint(*a, **kw) File "/c/dvlp/odoo/odoo/http.py", line 937, in call return self.method(*args, **kw) File "/c/dvlp/odoo/odoo/http.py", line 515, in response_wrap response = f(*args, **kw) File "/c/dvlp/odoo/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/c/dvlp/odoo/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/c/dvlp/odoo/odoo/api.py", line 687, in call_kw return call_kw_model(method, model, args, kwargs) File "/c/dvlp/odoo/odoo/api.py", line 672, in call_kw_model result = method(recs, *args, **kwargs) File "/c/dvlp/odoo/custom-addons/OpenHRMS/hrms_dashboard/models/hrms_dashboard.py", line 409, in get_attrition_rate match_join = list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:2], month_join))[0]['count'] IndexError: list index out of range
Can you please specify the version ?
It happens on branch 11.0
Same error on v11, Fixed by downloading updating the new repo
I've fixed it for me:
@api.model
def get_attrition_rate(self):
month_attrition = []
monthly_join_resign = self.join_resign_trends()
month_join = monthly_join_resign[0]['values']
month_resign = monthly_join_resign[1]['values']
sql = """
SELECT (date_trunc('month', CURRENT_DATE))::date - interval '1' month * s.a AS month_start
FROM generate_series(0,11,1) AS s(a);"""
self._cr.execute(sql)
month_start_list = self._cr.fetchall()
for month_date in month_start_list:
self._cr.execute("""select count(id), to_char(date '%s', 'Month YYYY') as l_month from hr_employee
where resign_date > date '%s' or resign_date is null and joining_date < date '%s'
""" % (month_date[0], month_date[0], month_date[0],))
month_emp = self._cr.fetchone()
# month_emp = (month_emp[0], month_emp[1].split(' ')[:1][0].strip()[:3])
month_join_filter = filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_join)
match_join = 0
if len(tuple(month_join_filter)) > 0:
match_join = list(month_join_filter)[0]['count']
month_resign_filter = filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_resign)
match_resign = 0
if len(tuple(month_resign_filter)) > 0:
match_resign = list(month_resign_filter)[0]['count']
month_avg = (month_emp[0] + match_join - match_resign + month_emp[0]) / 2
attrition_rate = (match_resign / month_avg) * 100 if month_avg != 0 else 0
vals = {
# 'month': month_emp[1].split(' ')[:1][0].strip()[:3] + ' ' + month_emp[1].split(' ')[-1:][0],
'month': month_emp[1].split(' ')[:1][0].strip()[:3],
'attrition_rate': round(float(attrition_rate), 2)
}
month_attrition.append(vals)
return month_attrition