İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

IndexError: list index out of range need a help

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
2 Cevaplar
16757 Görünümler
Avatar
ABU K

Here   I attached entire .py code and .xml file one of button event returns  IndexError: list index out of range  error need a help 

function name is

  def  check_eligibility(

.py file-------------------


from osv import osv,fields
import time
from datetime import datetime
from datetime import timedelta

class hr_employee(osv.osv):

     _name='hr.employee'
     _inherit=['hr.employee','mail.thread']

     _columns={
              'date_of_join' :fields.date('Date of Join',required=True),
              'current_date':fields.date('Applied date',require=True),
              'eligible_details':fields.char('Eligibility Details'),
              'visaexpiry_date':fields.date('Visa Expiry Date'),
               'residence_expiry_date':fields.date('Residence Expiry',required=True),
               'work_permit_date':fields.date('Work Permit'),
               'insurance_expiry_date':fields.date('Insurance date'),
               'license_date':fields.date('License date',required=True)
                             }
     def  check_eligibility(self,cr,uid,ids,context=None):
         day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context)
     print "day_obj#############################",day_obj
         
         calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,ids,['interval','criteria','scheme_id'],context=context)
     print "day_obj#############################",calc_vacation
         
         
         dateformat="%Y-%m-%d"
         d1=datetime.strptime(day_obj[0]['date_of_join'],dateformat)
         d2=datetime.strptime(day_obj[0]['current_date'],dateformat)
         v1=d2-d1
         
         total_days=v1.days
       
         if total_days<=calc_vacation[0]['interval'] and total_days>400:
             msg=calc_vacation[0]['criteria']
         elif total_days<=calc_vacation[0]['interval']:
              msg=calc_vacation[0]['criteria']
         else:
             msg="You are not eligible"
         vals={
               'eligible_details':msg
               }
         self.write(cr,uid,ids,vals)
        
         return True

     def check_residence_expiry_date(self, cr, uid, ids, context=None):
        print "total_days#############################"
         
        expir_var=self.read(cr,uid,ids,['residence_expiry_date','current_date'],context=context)
        dateformat="%Y-%m-%d"
        d1=datetime.strptime(expir_var[0]['residence_expiry_date'],dateformat)
        d2=datetime.strptime(expir_var[0]['current_date'],dateformat)
        v1=d1-d2
        total_days=v1.days
        print "total_days#############################",total_days
        
        if total_days<=20:
            print "total_days#############################",total_days

            ir_model_data = self.pool.get('ir.model.data')
            try:
                compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
            except ValueError:
                compose_form_id = False
    
            return {
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'mail.compose.message',
                'views': [(compose_form_id, 'form')],
                'view_id': compose_form_id,
                'target': 'new',
                'context': {},
            }
    
     def check_license_expiry(self, cr, uid, ids, context=None):
                print "total_days#############################"
                expir_var=self.read(cr,uid,ids,['license_date','current_date'],context=context)
                dateformat="%Y-%m-%d"
                d1=datetime.strptime(expir_var[0]['license_date'],dateformat)
                d2=datetime.strptime(expir_var[0]['current_date'],dateformat)
                v1=d1-d2
                total_days=v1.days
                print "total_days#############################",total_days
                
                if total_days<=20:
                    print "total_days#############################",total_days
        
                    ir_model_data = self.pool.get('ir.model.data')
                    try:
                        compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
                    except ValueError:
                        compose_form_id = False
            
                    return {
                        'type': 'ir.actions.act_window',
                        'view_type': 'form',
                        'view_mode': 'form',
                        'res_model': 'mail.compose.message',
                        'views': [(compose_form_id, 'form')],
                        'view_id': compose_form_id,
                        'target': 'new',
                        'context': {},
                    }
    
            
    
     
hr_employee()
     
class scheme_type_info(osv.osv):
    
    _name='scheme.type.info'
    
    _columns={
              'scheme_id':fields.integer('Scheme Type',required=True,size=50),
              'interval':fields.integer('interval type ',required=True,size=64),
              'criteria':fields.text('vacation criteria',required=True,size=50),
              'active':fields.boolean('Active')
              }
    
scheme_type_info()
     
     
#      if working>182
#
#  eligible for 2 ticket and 50000
#
# if working<182
#
#     eligible for 1 ticket and 30000
     

 

   .xml file------------------------

 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
                    
<record  model="ir.ui.view"  id="hr_employee_inherited">
                <field name="name">hr employee inherited</field>
                <field name="model">hr.employee</field>
                <field name="inherit_id"  ref="hr.view_employee_form"/>
               <field name="arch"  type="xml">
               <xpath expr=" /form/sheet/notebook/page/group/group/field[@name='active' ]"  position="after">
               <field name="date_of_join" />
               </xpath>
               
               
             <xpath expr="/form/sheet/notebook/page[@string='HR Settings']" position="after">
                <page string="Allowance Details">
                <group><field name="date_of_join"/></group>
                <group><field name="current_date"/></group>
                <group><field name="eligible_details"/></group>
                <button name="check_eligibility" string="Check Eligibility"
                                type="object" icon="gtk-apply" />
                </page>
               </xpath>
               
               <xpath expr=" /form/sheet/notebook/page[2]/group/group[4]/field[@name='birthday']"  position="after">
                           
        <group> <group><field name="visaexpiry_date" />
               <field name="residence_expiry_date" />
                <field name="work_permit_date" />
                <field name="insurance_expiry_date" />
                 <field name="license_date" /></group>
        </group>
                <group><button name="check_license_expiry" string="License Expiry"
                                type="object" icon="gtk-apply" />
                    <button name="check_residence_expiry_date" string="Residence Expiry"
                                type="object" icon="gtk-apply" /></group>
                       
               </xpath>
               </field>
 </record>
 
 
 <record id="criteria_tree_view_id" model="ir.ui.view">
                <field name="name">scheme.type.info.tree</field>
                <field name="model">scheme.type.info</field>
                <field name="arch" type="xml">
                    <tree string="Vacation Details">                                    
                        <field name="scheme_id"/>
                        <field name="interval"/>
                        <field name="criteria"/>
                        
                    </tree>
                </field>    
    </record>
    
    
    <record id="criteria_form_view_id" model="ir.ui.view">
                <field name="name">scheme.type.info.form</field>
                <field name="model">scheme.type.info</field>
                <field name="arch" type="xml">
                    <form string="Vacation Details">                                    
                        <group><field name="scheme_id"/>
                        <field name="interval"/>
                        <field name="criteria"/>
                        
                        <field name="active"/></group>
                        
                    </form>
                </field>    
    </record>
    
    
    <record id="criteria_action_id" model="ir.actions.act_window">
        <field name="name">Vacation Details</field>
        <field name="res_model">scheme.type.info</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        
    </record>
    
<menuitem id="menu_vacation_id" name="Vacation Details" parent="hr.menu_hr_main" action="criteria_action_id"/>
 
     
                
    </data>
</openerp>

-------------------------------------------------------

This is the error log

 

Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/server/openerp/addons/mecha_module/mech_info.py", line 39, in check_eligibility msg=calc_vacation[0]['criteria'] IndexError: list index out of range

 

 

 

 

0
Avatar
Vazgeç
Avatar
Emipro Technologies Pvt. Ltd.
En İyi Yanıt

You can do before read, like

if ids:

   day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context)

and i see here, you use same ids for different model,

Try with above code if got problem, let me know...

0
Avatar
Vazgeç
ABU K
Üretici

Hi ,Thanks for your replay .But I got the same error.. I think this variable data have raised the error calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,ids,['interval','criteria','scheme_id'],context=context) print "day_obj#############################",calc_vacation How to redefine my code

ABU K
Üretici

if ids: day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context) print "day_obj#############################",day_obj calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,ids,['interval','criteria','scheme_id'],context=context) print "day_obj#############################",calc_vacation dateformat="%Y-%m-%d" d1=datetime.strptime(day_obj[0]['date_of_join'],dateformat) d2=datetime.strptime(day_obj[0]['current_date'],dateformat) v1=d2-d1 total_days=v1.days

Emipro Technologies Pvt. Ltd.

i think in your code there is no use of "calc_vacation", so for the testing you can move farther by putting comment on that both lines.

ABU K
Üretici

No This is the purpose i want to calculate a criteria based on some date difference so first i create one model for setting the criteria and another for date calculation This the actual purpose of this code ..please read def check_eligibility(self,cr,uid,ids,context=None): day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context) print "day_obj#############################",day_obj calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,ids,['interval','criteria','scheme_id'],context=context) print "day_obj#############################",calc_vacation dateformat="%Y-%m-%d" d1=datetime.strptime(day_obj[0]['date_of_join'],dateformat) d2=datetime.strptime(day_obj[0]['current_date'],dateformat) v1=d2-d1 total_days=v1.days if total_days400: msg=calc_vacation[0]['criteria'] elif total_days

Avatar
Ludo - 21South
En İyi Yanıt

There is a lot of code there, which may or may not be relevant, but I see no stack for the error you receive. There are multiple lists you address, each of them could be causing the error.

Please post the stack itself, not just the error line.

0
Avatar
Vazgeç
ABU K
Üretici

This the error stack----------- Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/server/openerp/addons/mecha_module/mech_info.py", line 39, in check_eligibility msg=calc_vacation[0]['criteria'] IndexError: list index out of rang

Ludo - 21South

Apparently sometimes your variable "calc_vacation" is empty. If you absolutely need this variable, then it would be best to raise an exeption at the beginning of your method, something like: if not calc_vacation: raise orm.except_orm('Error', 'Unable to continue, please provide calc_vacation') If it is not required, then before entering the if-statement, provide an additional check, something like so: if calc_vacation: if total_days400: msg=calc_vacation[0]['criteria'] elif total_days

OdooBot
Hi Ludo,

Here I attached my module.. and screen shot what i required exactly..so please help me to solve this error ,

error is from menu Human resources->employees->allowance details click on check eligibility button




On Wed, Jun 11, 2014 at 6:04 PM, Ludo - Neobis <ludo@neobis.nl> wrote:

Apparently sometimes your variable "calc_vacation" is empty. If you absolutely need this variable, then it would be best to raise an exeption at the beginning of your method, something like: if not calc_vacation: raise orm.except_orm('Error', 'Unable to continue, please provide calc_vacation') If it is not required, then before entering the if-statement, provide an additional check, something like so: if calc_vacation: if total_days400: msg=calc_vacation[0]['criteria'] elif total_days

--
Ludo - Neobis Sent by OpenERP S.A. using OpenERP. Access your messages and documents in Odoo



--
Thanks&Regards
Libu Koshy
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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