使用action_done函数执行库存移动?

时间:2016-03-07 08:43:29

标签: python-2.7 openerp odoo-8 openerp-7 openerp-8

我试图两次致电action_done()来执行两次股票走势:

  • 将old_product_id从源头移至分散
  • 将新产品_id从分散移至源

如何将res{}字典传递给函数action_done(self,cr,uid,ids,context=None) 进行库存移动,它应该返回什么?

 class my_class(osv.osv):
  ...
  ...
 def action_move(self, cr , uid,  res, context=None)
    if context is None:
        context= {}
    move_obj = self.pool.get('stock.move')
    res1 = {
          'product_id': old_product_id,
          'location_id': location_id,
          'location_dest_id': location_dest_id,
          'product_uom_qty': product_qty,
          }
    res2 = {
          'product_id': new_product_id,
          'location_id': location_dest_id,
          'location_dest_id': location_id,
          'product_uom_qty': product_qty,
          }
    move_obj.action_done(self,cr, uid, res, context=context)
    move_obj.action_done(self,cr, uid, res2, context=context)
    return ????

1 个答案:

答案 0 :(得分:0)

我认为你的问题是你还没有随时创建记录" stock.move"。您必须首先创建" stock.move",然后保持股票的ID移动并发送完成的操作。像这样:

move_obj.action_done (self, cr, uid, beef, context = context)

move_obj.action_done (self, cr, uid, stock_move_res._d, context = context)