Odoo Help

Welcome!

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.

1

How can I populate selection type field when triggered by on_change method?

By
splucena
on 10/4/13, 5:23 AM 894 views

How can I display values on my second selection field type based on the value of the first selection field type. Example,

  • First Selection has values {('1','Stock'),('2','Output')}.
  • Second selection should display values depending on the key of my first selection.

Code:

def on_change_location_dest(self, cr, uid, ids, location_dest, context=None):
    x = {}
    x = location_dest
    sql_res = cr.execute("select sm.picking_id, sp.name from stock_move sm inner join stock_picking sp on sm.picking_id = sp.id where sm.location_dest_id=" + str(x))
    res = cr.fetchall()
    return {'value':{'reference_code': res}}

#I have a method that populates my first selection field
'location_dest': fields.selection(_get_location_dest_,'Division', required=True),
'reference_code': fields.selection(on_change_location_dest,'RIS No.:', required=True),

# When on_change method is triggered, It should populate my second selection ---It's not happening.
<field name="location_dest" on_change="on_change_location_dest(reference_code)"/>
    <newline />
    <field name="reference_code" />

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

0 follower(s)

Stats

Asked: 10/4/13, 5:23 AM
Seen: 894 times
Last updated: 3/16/15, 8:10 AM