2017-07-20 3 views
0

セールスチームセールスオーダーが確定し、ピッキングが作成されると直接ピッキングする際に参照してください。picking-odooの受注明細参照を設定します

しかし、私はこれをどのように達成できるかについて十分なヒントを得ていませんでした。受注確認時に呼び出される方法は以下の通りですので、

def action_button_confirm(self, cr, uid, ids, context=None): 
    if not context: 
     context = {} 
    assert len(ids) == 1, 'This option should only be used for a single id at a time.' 
    self.signal_workflow(cr, uid, ids, 'order_confirm') 
    if context.get('send_email'): 
     self.force_quotation_send(cr, uid, ids, context=context) 
    return True 

ここでピッキングにどのように渡すことができますか?

目的:

私の目的は、/出荷を選んで営業チームの参照を設定することです。

答えて

0

私はピッキングを作成する場所からその方法を得ました。だから私はちょうどそれを継承し、私のコードを追加しました。 action_ship_createは、受注から出荷作成時に常に呼び出されます。

@api.cr_uid_ids_context 
    def action_ship_create(self,cr,uid,ids,context={}): 
     result=super(sale_order,self).action_ship_create(cr,uid,ids,context=context) 
     for order in self.browse(cr,uid,ids,context=context): 
      order.picking_ids.write({'section_id':order.section_id.id}) 
     return result 
1

これは簡単ではありません。 Odooはstock.moveを作成するのにprocurement.orderを使用し、stock.pickingを作成するために使用します。問題:ピッキングに2つ以上の受注がある可能性があります。したがって、複数の販売チームが参照される可能性があります。

しかし、計算フィールドを使用しよう:

section_id = fields.Many2one(
    comodel_name="crm.case.section", string="Sales Team", 
    compute="_compute_section_id") 

@api.multi 
def _compute_section_id(self): 
    for picking in self: 
     section_ids = set() 
     for move in picking.move_lines: 
      if move.sale_line_id.order_id.section_id 
       section_ids.add(move.sale_line_id.order_id.section_id.id) 
     if len(section_ids) == 1: 
      picking.section_id = section_ids.pop() 

また、関連分野を使用することができますが、それは本当に悪い副作用を持つことができます。 Odooが最初の動きを取るので。

section_id = fields.Many2one(
    comodel_name="crm.case.section", string="Sales Team", 
    related="move_lines.sale_line_id.order_id.section_id") 
+0

ありがとうございました。私たちは常に 'move.sale_line_id'を取得しますか? –

+0

新しいAPIは、これらのbrowse_null_recordエラーをもう投げていません;なぜなら、それはいつもうまくいくはずです。 – CZoellner

+0

バージョン8では、ピッキング/移動の販売注文および受注明細と直接の関係はありません。あなたのソリューションが好きなように、それはとても良いです。 –

関連する問題