CybroOdoo / OpenHRMS

GNU Affero General Public License v3.0
134 stars 221 forks source link

Error on the dashboard page #46

Open katerius opened 4 years ago

katerius commented 4 years ago

Hello, This is a fresh install of Openhrms on Odoo 13 CE.

Everytime i load the dashboard page this error show up :

Odoo Server Error

Traceback (most recent call last):
  File "/opt/openhrms/odoo/http.py", line 619, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/openhrms/odoo/http.py", line 309, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/openhrms/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/opt/openhrms/odoo/http.py", line 664, in dispatch
    result = self._call_function(**self.params)
  File "/opt/openhrms/odoo/http.py", line 345, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/openhrms/odoo/service/model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/openhrms/odoo/http.py", line 338, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/openhrms/odoo/http.py", line 909, in __call__
    return self.method(*args, **kw)
  File "/opt/openhrms/odoo/http.py", line 510, in response_wrap
    response = f(*args, **kw)
  File "/opt/openhrms/addons/web/controllers/main.py", line 1319, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/openhrms/addons/web/controllers/main.py", line 1311, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/openhrms/odoo/api.py", line 391, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
  File "/opt/openhrms/odoo/api.py", line 364, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/opt/openhrms/openhrms/hrms_dashboard/models/hrms_dashboard.py", line 383, in get_attrition_rate
    match_join = list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_join))[0]['count']
IndexError: list index out of range

I don't understand why, this is because of the fresh install ? (no data ?)

katerius commented 4 years ago

Same on Odoo 12 CE

Erreur:
Odoo Server Error

Traceback (most recent call last):
  File "/opt/openhrms/odoo/http.py", line 656, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/openhrms/odoo/http.py", line 314, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/openhrms/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/opt/openhrms/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)
  File "/opt/openhrms/odoo/http.py", line 346, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/openhrms/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/openhrms/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/openhrms/odoo/http.py", line 941, in __call__
    return self.method(*args, **kw)
  File "/opt/openhrms/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/opt/openhrms/addons/web/controllers/main.py", line 962, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/openhrms/addons/web/controllers/main.py", line 954, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/openhrms/odoo/api.py", line 755, in call_kw
    return _call_kw_model(method, model, args, kwargs)
  File "/opt/openhrms/odoo/api.py", line 728, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/opt/openhrms/openhrms/hrms_dashboard/models/hrms_dashboard.py", line 400, in get_attrition_rate
    match_join = list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_join))[0]['count']
IndexError: list index out of range
riyazitsme commented 4 years ago

DASHBOARD ERROR WHILE LOGING IN WITH USERS WITH ALLOWED WITH MULTIPLE COMPANY IN ODOO 11

Traceback (most recent call last): File "/opt/openhrms/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/openhrms/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/opt/openhrms/odoo/tools/pycompat.py", line 87, in reraise raise value File "/opt/openhrms/odoo/http.py", line 695, in dispatch result = self._call_function(self.params) File "/opt/openhrms/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/opt/openhrms/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/opt/openhrms/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/opt/openhrms/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/opt/openhrms/odoo/http.py", line 517, in response_wrap response = f(args, kw) File "/opt/openhrms/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/opt/openhrms/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/openhrms/odoo/api.py", line 697, in call_kw return call_kw_model(method, model, args, kwargs) File "/opt/openhrms/odoo/api.py", line 682, in call_kw_model result = method(recs, *args, *kwargs) File "/opt/openhrms/openhrms/hrms_dashboard/models/hrms_dashboard.py", line 168, in get_upcoming cr.execute(sql) File "/opt/openhrms/odoo/sql_db.py", line 155, in wrapper return f(self, args, **kwargs) File "/opt/openhrms/odoo/sql_db.py", line 232, in execute res = self._obj.execute(query, params) psycopg2.ProgrammingError: operator does not exist: integer = boolean LINE 15: and hea.employee = False)) ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

hana-briki commented 3 years ago

Hello any update about this error when loading the dashboard ? i'm using Odoo 13 CE

list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_join))[0][
IndexError: list index out of range
ricardon85 commented 3 years ago

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