Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
3863 Weergaven

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)

        try:
            result[order.id] = production[0].routing_id
            return result[order.id]
        except:
            result[order.id] = 0
            return result[order.id]

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

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jul. 25
413
0
jul. 25
446
1
mei 25
940
0
mrt. 25
1064
0
mrt. 25
1010