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 populate a lot of fields?

Carlos Llamacho
on 6/14/13, 4:09 PM 636 views

What is wrong with this function? Is supposed to retrieve the routing_id of the object mrp.production and store it in the mrp.production.workcenter.line one, but doing everything but that. Is there something wrong with the logic?

def set_routing_id(self, cr, uid, ids, context=None): """Routing_id automatically fills the records using ORM methods."""

    mrp_production_object = self.pool.get("mrp.production")
    work_orders = self.browse(cr, uid, ids, context=None)

    result ={}

    for order in work_orders:

        ids_production = mrp_production_object.search(cr, uid, [('id','=',order.production_id)], limit=1, context=None)
        production = mrp_production_object.browse(cr, uid, ids_production, context=None)

            result[order.id] = production[0].routing_id
            return result[order.id]
            result[order.id] = 0
            return result[order.id]

_columns = { 'routing_id':fields.integer('routing_id'), } _defaults = { 'routing_id':set_routing_id



| 4 4 8
Ahmedabad, India

Odoo Expert

On 6/15/13, 4:17 AM

Hi Carlos,

In set_routing_method production[0].routing_id will give you routing_id. And you have taken routing_id as integer field. There is no meaning to take routing_id as an integer field it just give you database id instead make it as many2one field of routing object.

'task_id': fields.many2one('routing object', 'Routing'),

Then there will be no problem. Thanks.

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/14/13, 4:09 PM
Seen: 636 times
Last updated: 3/16/15, 8:10 AM