2016-10-22 2 views
0

odoo에서 컨텍스트 란 무엇입니까?컨텍스트 란 무엇입니까? 왜 odoo에서 사용합니까?

def change_product_qty(self, cr, uid, ids, context=None): 
    """ Changes the Product Quantity by making a Physical Inventory. """ 
    if context is None: 
     context = {} 

    inventory_obj = self.pool.get('stock.inventory') 
    inventory_line_obj = self.pool.get('stock.inventory.line') 

    for data in self.browse(cr, uid, ids, context=context): 
     if data.new_quantity < 0: 
      raise UserError(_('Quantity cannot be negative.')) 
     ctx = context.copy() 
     ctx['location'] = data.location_id.id 
     ctx['lot_id'] = data.lot_id.id 
     if data.product_id.id and data.lot_id.id: 
      filter = 'none' 
     elif data.product_id.id: 
      filter = 'product' 
     else: 
      filter = 'none' 
     inventory_id = inventory_obj.create(cr, uid, { 
      'name': _('INV: %s') % tools.ustr(data.product_id.name), 
      'filter': filter, 
      'product_id': data.product_id.id, 
      'location_id': data.location_id.id, 
      'lot_id': data.lot_id.id}, context=context) 

     line_data = self._prepare_inventory_line(cr, uid, inventory_id, data, context=context) 

     inventory_line_obj.create(cr, uid, line_data, context=context) 
     inventory_obj.action_done(cr, uid, [inventory_id], context=context) 
    return {} 

답변

0

컨텍스트 사전이 사용자 ID, 언어, 시간대 및 추가 된 잠재적으로 키 값 쌍에 기록 함유 설명되어있는 예를주세요. 모델과 뷰간에 데이터를 전달하는 수단으로 의미합니다. Android에서는 인 텐트 또는 활동을 시작할 때 데이터를 전달하는 것과 유사합니다.

+0

예를 들어 업데이트 할 예정입니다. –

관련 문제