Odoo Help


how to remove the duplicate number of elements in list?

Demirel yakito
on 1/20/15, 4:39 AM 2,288 views

iam hving list with repeated elements. so in this case how to delete the duplicate elements in the list using python?

On 1/20/15, 4:40 AM

For example:

def formatList(seq):
    seen = set()
    seen_add = seen.add
    return [ x for x in seq if not (x in seen or seen_add(x))]

There are loads of topics about this on stackoverflow and Google. This example is taken from http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order and also keeps the order of your list!


A second option could be to create a second list, which only contains the clean values. In case you would like to keep both lists.

for i in mylist:
     if i not in newlist:

list = set(list) is this correct?

Demirel yakito
on 1/20/15, 4:49 AM
On 1/20/15, 6:16 AM

I usually used list_wo_no_duplicate = list(set(list_with_ducplicates))  to remove duplicates.  Although I think there is no harm for not setting the variable to list again as set in most cases.

Odoo For Beginners
On 6/14/17, 1:41 PM

Take a look at this blog 

How to hide an options from 'More' button?

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: 1/20/15, 4:39 AM
Seen: 2288 times
Last updated: 6/14/17, 1:41 PM