Odoo Help


How to populate a lot of fields?

Carlos Llamacho
on 6/14/13, 4:09 PM 1,057 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.

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

1 follower(s)


Asked: 6/14/13, 4:09 PM
Seen: 1057 times
Last updated: 3/16/15, 8:10 AM