Odoo Help


This community 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.


Changing selection field content

on 12/9/15, 5:23 AM 370 views


I need to change my slection elements after change field1 .

this code doesn't work , who has an idea how to fix it ?

_columns = {

'field1': fields.selection([('1', 'A'), ('1', 'B')], 'my filed 1'),

'field2': fields.selection([('aa', 'C'), ('bb', 'D')], 'my filed 2'),


def onchange_field2(self, cr, uid, ids,field1,context=None):

    lst= [('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')]


        lst.remove([item for item in lst if item[0] == '5'][0])

    except IndexError as e:


    v = {'field2': lst}

    return {'value': v}

thank you


on 12/10/15, 5:23 PM
Krupesh Laiya
On 12/10/15, 6:15 AM

Yes you can not change using onchage of selection field value. It the collection of static value. you only used those value for selection which you had been define while creating selection field.

Thank you.


Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 12/9/15, 5:31 AM

Sorry but selection fields doesn't allow you to change the values like you are doing, they are a kind of static collection of options/values to select just one. For doing something like that you need to change your field definition to a many2one and apply a domain to the field that restrict the results to the matching records and the domain could be build and returned from an onchange

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 12/9/15, 5:23 AM
Seen: 370 times
Last updated: 12/10/15, 5:23 PM