1

o我从中选择相同的字段mo.queue,我想将其保存到procurement.order表格中

我的代码如下所示:

def action_ship_create(self, cr, uid, ids, id_queue, context=None):
    queue_obj = self.pool.get('mo.queue'). browse (cr, uid, id_queue, context=context)
    mo_name = queue_obj.name 
    query_param = (mo_name)
    cr.execute("select origin,create_date,product_uos_qty,product_qty,name,city from mo_queue",(query_param,))
    ads = cr.fetchone()
    name = ads and ads [0] or None
    print "======================"
    print name
    print "======================"

    val = { 'origin': name,
          } 
    print "======================"
    print val
    print "======================"  

    return {'value': val }  


    proc_id = self.pool.get('procurement.order').create(cr, uid, {
        'origin':origin,
    })
    proc_ids.append(proc_id)

打印的结果是:

print name = SO013

print val = {'origin': u'SO013'}

但是数据没有插入到procurement.order表中。

4

1 回答 1

1

您的代码我在 return 语句之后看起来像这样不执行任何操作在 return 之前放置 cdeo 并且您的代码需要大量调整,例如不要使用 SQL 注入,这不是一个好主意。

def action_ship_create(self, cr, uid, ids, id_queue, context=None):
        queue_obj = self.pool.get('mo.queue'). browse (cr, uid, id_queue, context=context)
        queue_model = self.poo.get(queue_obj.name)
        procurement_pool = self.pool.get('procurement.order')
        qsids = queue_model.search(cr, uid, )
        for record in queue_model.browse(cr, uid, qsids):
          if record.origin:
               #this will crate a new record the table procurement.order so 
               #field values may be not enough so you can update logic
               #and If you want to update record value you need a proc ids and you can do it.
               procurement_pool.create(cr, uid, {'origin':record.origin})
        return {'value': {'origin': record.origin}}  

希望这会帮助你让我知道我失踪了。

谢谢你

于 2012-07-20T04:56:28.790 回答