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.


How to automatically select a field?

Carlos Llamacho
on 6/13/13, 5:36 PM 1,066 views


What would consider to be the best way to fill a field automatically when creating an order?

I mean, in my instance, when I create a new production order, this in turn creates work orders required to comply with that order, in theory, the only thing that should be put to complete is the product and quantity. But that leaves me empty routing_id field that I need to be completed automatically depending on the product selected.

I think, given my limited experience with OpenERP, that this can be done by looking for the product that is created with the order, taking the routing id from a couple of records and fill the field with this data. That is a first impression on how to do it.

But I wanted to confirm if anyone knows or has any idea how to do it using some other method.

Thank you very much.



| 4 4 8
Ahmedabad, India

Odoo Expert

On 6/14/13, 2:55 AM

Hi Carlos, there are some methods available to fill your field automatically.

(1) You can write method in _defaults of your object.

For example,

def _get_routing(self, cr, uid, context=None):
    // Your code & return the routing_id you want
    return routing_id[0]

_defaults = {
         'routing_id' : _get_routing,

(2) On change of product_id you can return routing_id.

(3) You can overwrite create method and fill your field.


That what i thought. I think am gonna go with the first option. I am more familiar with that than the last 2. Thanks.

Carlos Llamacho
on 6/14/13, 11:54 AM

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: 6/13/13, 5:36 PM
Seen: 1066 times
Last updated: 3/16/15, 8:10 AM