Odoo Help


Change the value of a fields.selection

on 5/23/16, 8:48 AM 1,051 views

How can I change the value of a fields.selection in a function? 

def fuse_tickets(self, cr, uid, ids, context=None):    
    active_tickets = context.get('active_tickets')    
    active_tickets = ast.literal_eval(active_tickets)    
    ticket = context.get('ticket')    
    for active in active_tickets:        
        if active != ticket:            
            status = self.pool.get('tickets').browse(cr, uid, active, context=context)            
    ? -->   status.update('value': {'fused', 'fused'}) <-- ?

This is the function that I have created but I can't change the status (that is the fields.selection) to another option that it has defined in the .py

Rubén Cabrera
On 5/23/16, 1:58 PM

If I get it right, what you want is to assign a new value to that field.

You can modify any field from the model with:

 self.value = 'value_to_assign'

In your function it should be just:

 self.value = 'fused'

In the case of a selection field, you just need to give the value part of the Tuple, not the label.


I tried to do that but it doesn't work. def fuse_tickets(self, cr, uid, ids, context=None): active_tickets = context.get('active_tickets') active_tickets = ast.literal_eval(active_tickets) ticket = context.get('ticket') for active in active_tickets: if active != ticket: fused = self.pool.get('tickets').browse(cr, uid, active, context=context) fused.fused= 'fused' My selection field is called 'fused' and the only option that it has is 'fused' Thanks!

on 5/24/16, 2:46 AM

Might be a typo, but... fused.fused = 'fused' doesn't seem right. First, it MUST say self, then a dot and then the name of the field: self.value = then you assign the value for the selection as a string.

Rubén Cabrera
on 5/24/16, 3:26 AM

There, it doesn't seen right, but fused is a variable that get the specific object ***fused = self.pool.get('tickets').browse(cr, uid, active, context=context)*** And then I access to the selection field and I equal to the value *** fused.fused = 'fused' *** Is it wrong?

on 5/24/16, 4:46 AM
Juan Vicente Pascual
On 5/23/16, 9:59 AM


if you want to add a new value, just have to redefine the field with inheritance, adding the values you need, like

state = fields.Selection([ ('draft', 'Draft'), ('sent', 'Quotation Sent'), ('done', 'Done'),('your_value','Your Value') ], 'Status', ......

then you can asign your value, like


Kind Regards,


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

2 follower(s)


Asked: 5/23/16, 8:48 AM
Seen: 1051 times
Last updated: 5/23/16, 1:58 PM