Your question does not clearly explain what you want to do nor what you tried. You say you have an error but you do not say what is the error message (and trace). Your code example is not complete enough to understand properly.
Still, here are a few pointers:
- How to obtain the value chosen by the user depends on where you do it: in an
on_change
method, in a fields.function
, when overriding one of the base ORM methods, etc.
- Have a look at the OpenERP Technical memento, it contains examples for these various use cases.
- The selection field in your example has 2 possible hardcoded integer values: 11 or 12. This is rather unusual but supported. Most selection fields use string values though. In this case when you
read()
or browse()
a record from the model in which this field is defined, you will get the value as an int (11 or 12) or False
if the field was left empty (if it's not required).
Here's a random example based on the little information you provided:
Imagine you put an on_change on your field in the XML view:
<field name="seq_choosed" on_change="on_change_seq_choosed(seq_choosed)"/>
<field name="seq_num"/>
Then you could do something like the following:
def on_change_seq_choosed(self, cr, uid, ids, seq_choosed, context=None):
# on_change returns a dict
result = {
'value': {}
}
# selected value is explicitly passed in seq_choosed parameter in XML def
if seq_choosed:
seq_num = self.pool.get('ir.sequence').get_id(cr, uid, seq_choosed, context=context)
result['value']['seq_num'] = seq_num
return result
That's not a very useful example, but if you want better answers you'll have to be a lot more specific in your question ;-)
Hope this will helps: https://learnopenerp.blogspot.com/2021/08/get-selection-field-value-instead-of-key-odoo.html