2016-03-07 34 views
1

我試圖打電話action_done()兩次執行兩個股票招式:使用action_done函數執行庫存移動?

  • 從移動源old_product_id從distination distination
  • 招新的product_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 ???? 

回答

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)