Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

How to resolve the error “IndexError: list index out of range”?

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
python3odoo11
3 Trả lời
65891 Lượt xem
Ảnh đại diện
Dhouha

I'm using Odoo 11 and I have installed openHRMS module but every time when I press on the dashboard menu it appears an error on this method:

IndexError: list index out of range

Ps: i tried to install this module on bitnami VM and it works whithout any problem but when i tried to installe it on ubuntu 18.04 it shows error

Any ideas on how to fix it?

 def join_resign_trends(self):
    cr = self._cr
    month_list = []
    join_trend = []
    resign_trend = []
    for i in range(11, -1, -1):
        last_month = datetime.now() - relativedelta(months=i)
        text = format(last_month, '%B %Y')
        month_list.append(text)
    for month in month_list:
        vals = {
            'l_month': month,
            'count': 0
        }
        join_trend.append(vals)
    for month in month_list:
        vals = {
            'l_month': month,
            'count': 0
        }
        resign_trend.append(vals)
    cr.execute('''select to_char(joining_date, 'Month YYYY') as l_month, count(id) from hr_employee 
    WHERE joining_date BETWEEN CURRENT_DATE - INTERVAL '12 months'
    AND CURRENT_DATE + interval '1 month - 1 day'
    group by l_month;''')
    join_data = cr.fetchall()
    cr.execute('''select to_char(resign_date, 'Month YYYY') as l_month, count(id) from hr_employee 
    WHERE resign_date BETWEEN CURRENT_DATE - INTERVAL '12 months'
    AND CURRENT_DATE + interval '1 month - 1 day'
    group by l_month;''')
    resign_data = cr.fetchall()

    for line in join_data:
        match = list(filter(lambda d: d['l_month'].replace(' ', '') == line[0].replace(' ', ''), join_trend))
        match[0]['count'] = line[1]
    for line in resign_data:
        match = list(filter(lambda d: d['l_month'].replace(' ', '') == line[0].replace(' ', ''), resign_trend))
        match[0]['count'] = line[1]
    for join in join_trend:
        join['l_month'] = join['l_month'].split(' ')[:1][0].strip()[:3]
    for resign in resign_trend:
        resign['l_month'] = resign['l_month'].split(' ')[:1][0].strip()[:3]
    graph_result = [{
        'name': 'Join',
        'values': join_trend
    }, {
        'name': 'Resign',
        'values': resign_trend
    }]
    return graph_result

 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])
        match_join = list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_join))[0]['count']
        match_resign = list(filter(lambda d: d['l_month'] == month_emp[1].split(' ')[:1][0].strip()[:3], month_resign))[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

traceback

   Traceback (most recent call last):
   File "/opt/openhrms/odoo/http.py", line 651, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/openhrms/odoo/http.py", line 310, 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 693, in dispatch
result = self._call_function(**self.params)
  File "/opt/openhrms/odoo/http.py", line 342, 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 335, in checked_call
result = self.endpoint(*a, **kw)
  File "/opt/openhrms/odoo/http.py", line 937, in __call__
return self.method(*args, **kw)
  File "/opt/openhrms/odoo/http.py", line 515, 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 687, in call_kw
return call_kw_model(method, model, args, kwargs)
 File "/opt/openhrms/odoo/api.py", line 672, in call_kw_model
result = method(recs, *args, **kwargs)
 File "/opt/openhrms/openhrms/hrms_dashboard/models/hrms_dashboard.py", line 384, in get_attrition_rate
monthly_join_resign = self.join_resign_trends()
 File "/opt/openhrms/openhrms/hrms_dashboard/models/hrms_dashboard.py", line 364, in join_resign_trends
match[0]['count'] = line[1]
IndexError: list index out of range
0
Ảnh đại diện
Huỷ bỏ
Yenthe Van Ginneken (Mainframe Monkey)

line[1] doesn't exist as line[] is empty (or only has [0]) which gives this error.

Dhouha
Tác giả

Thanks for your answer i tried to modify line[1] --> line[0] but it shows the same error

Ảnh đại diện
Bhaviraj Brahmkshatriya
Câu trả lời hay nhất

Hello Dhouda,

Put some print statements. May be it will help. i thing no data is coming into sql query, so it is blank list.

and it is blank list if you do list[0] even though it gives same error. So verify your code.

0
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
How to set a filter as default filter in odoo Đã xử lý
python3 odoo11
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 2 24
16914
How to set default stage to when recruitement record is created Đã xử lý
python3 odoo11
Ảnh đại diện
Ảnh đại diện
1
thg 12 22
5893
How to change the value of a field which depends on other fields automatically ? Đã xử lý
python3 odoo11
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 12 22
15830
how to modify fields of hr.attendance via a modification request automatically Đã xử lý
python3 odoo11
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 6 22
8003
how to update field of attendance via an attendance request modification
python3 odoo11
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 6 22
5914
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now