Odoo Help


List index out of range

on 5/23/16, 6:28 AM 383 views

Hi, I am trying to copy ids into a many2many field, but it throws list index out of range error. Can someone please help me where I am doing a mistake

def get_default_subject_ids(self):
    res = []
    if len(self.course_id.subject_ids):
        for subject in self.course_id.subject_ids :
        self.subject_ids= [0,0,res]
    return True
Debugged it and observed that it throws list index out of range @ self.subject_ids= [0,0,res]



i have tried that before, but it then throws

argument of type 'bool' is not iterable error

on 5/23/16, 7:42 AM

Jusab Sida (jsi)

--Jusab Sida (jsi)--
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 5/23/16, 7:31 AM


can you try this one?: self.subject_ids = [(6, 0, res)]

almost, check https://www.odoo.com/documentation/9.0/reference/orm.html#openerp.models.Model.write the command you want is probably 6, not 0

Martin Trigaux (mat)
on 5/23/16, 7:49 AM

Copy error! ;)

Jusab Sida (jsi)
on 5/23/16, 7:56 AM
On 5/23/16, 7:50 AM

for [(0,0,res)] it throws 'list' object has no attribute 'iteritems' error

and for 

[(6,0,res)] it throws argument of type 'bool' is not iterable error

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/23/16, 6:28 AM
Seen: 383 times
Last updated: 5/23/16, 7:50 AM