2014-09-01 39 views
0

我想從客戶發票退款創建收到的貨件,當客戶想要退貨時,我將創建退款的貸記單。如何將客戶發票寄給收貨

問題,我可以創建傳入貨件,這是類型等於和狀態等於草稿 但是當我按下按鈕確認。它改變類型等於出,並轉移到交貨單。

我該如何解決它。 請幫我。

代碼..

def _prepare_order_picking(self, cr, uid, order, context=None): 
     return { 
      'origin': order.number, 
      'date': self.date_to_datetime(cr, uid, order.date_invoice, context), 
      'type': 'in', 
      'move_type': 'direct', 
      'partner_id': order.partner_id.id, 
      'note': order.comment, 
      'invoice_state': 'none', 
      'company_id': order.company_id.id, 
      'move_lines' : [], 
     } 

def _prepare_order_line_move(self, cr, uid, order, line, picking_id, context=None): 
     warehouse = self.pool.get('stock.warehouse').search(cr, uid,[('company_id','=',order.company_id.id)],context=context) 
     location = self.pool.get('stock.warehouse').browse(cr, uid,warehouse[0],context=context) 
     location_id = location.lot_stock_id.id 
     output_id = location.lot_output_id.id 
     return { 
        'name': line.name or '', 
        'picking_id': picking_id, 
        'product_id': line.product_id.id, 
        'product_qty': line.quantity, 
        'product_uom': line.uos_id.id, 
        'product_uos': line.uos_id.id, 
        'date': self.date_to_datetime(cr, uid, order.date_invoice, context), 
        'date_expected': self.date_to_datetime(cr, uid, order.date_due, context), 
        'partner_id': order.partner_id.id, 
        'location_id': location_id, 
        'location_dest_id': output_id, 
        'tracking_id': False, 
        'state': 'draft', 
        'type':'in', 
        'company_id': order.company_id.id, 
        'price_unit': line.price_unit 

       } 

def create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None): 
     if not picking_id: 
      picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) 

     stock_move = self.pool.get('stock.move') 
     wf_service = netsvc.LocalService("workflow") 
     for order_line in order_lines: 
      if not order_line.product_id: 
       continue 
      if order_line.product_id.type in ('product', 'consu'): 
       move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context)) 

     return picking_id 
+0

我已經顯示我的代碼。 – user3583681 2014-09-01 03:22:14

回答

0

對於進貨,此舉的源位置是供應商的位置和目標位置是庫存位置。但是在這裏,您完成了與庫存地點相反的過程,這與客戶地點完全相同。更改股票移動的來源和目標位置

+0

謝謝。我會嘗試,你的意思是field_id和location_dest_id對嗎? – user3583681 2014-09-02 09:00:41

+0

感謝您的解決方案,它運作良好。 – user3583681 2014-09-02 09:56:29

相關問題