تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3869 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 25
414
0
يوليو 25
448
1
مايو 25
941
0
مارس 25
1065
0
مارس 25
1012