2015-10-21 53 views
1

我已經創建了一個嚮導,我從其中啓用了報告打印的另一個模型放置了many2one字段[名稱]。這裏發生了什麼是當我選擇一個記錄&點擊打印按鈕它只打印空報告。因此有可能通過這裏獲取數據報告。如何將自定義模型的字段值傳遞給Qweb報告?

def print_report(self, cr, uid, ids, context=None): 

    ob=self.pool.get('book.room') 
    wizard=self.browse(cr,uid,ids,context=context) 


    datas = { 
     'ids': wizard.name, 
     'model': 'book.room', 
     'form': ob.browse(cr, uid, wizard.name)#[-1] 
     # 'form': [{'create_uid': (1, u'Administrator'), 'create_date': '2015-10-20 10:32:42', 'name': (1, u'Nani'), '__last_update': '2015-10-20 10:32:42', 'date_end': '12/10/2015', 'date_start': "13/12/1201", 'write_uid': (1, u'Administrator'), 'write_date': '2015-10-20 10:32:42', 'display_name': u'Nani', 'id': 18}] 
    } 

    print datas.get('form') 

    # print datas,'88888888888888' 
    # print datas['form'],'9999999999999' 

    return { 
     'type': 'ir.actions.report.xml', 
     'report_name': 'hotel_mng.Booking_Details', 
     'datas': datas, 
    } 

在此先感謝

回答

1
class print_report(osv.TransientModel): 
_name='report.wizard' 
_columns={ 
    'room1':fields.many2one('hotel.allroom','roomnum','Room No.') 
} 
    def print_report(self, cr, uid, ids, context=None): 
     current=self.browse(cr,uid,ids) 
     obj=self.pool.get('book.room') 
     k=obj.search(cr,uid,[('name','=',current.name.name)],context=context) 


    context = {} 
    data = self.read(cr, uid, ids)[0] 


    datas = { 
    'ids': k, 
    'model': 'report.wizard', 
    'form': data, 
    'context':context 
    } 
    return{ 
     'type' : 'ir.actions.report.xml', 
     'report_name' : 'hotel_mng.Booking_Details', 
     'datas' : datas, 
     } 

print_report() 

上面的代碼工作對我來說很好..從裁判需要的名字。模型和打印報告謝謝

0
def print_report(self, cr, uid, ids, context=None): 
     datas = {} 
     a=[] 
     print "---------------------------------------------------------------" 
     for phone in self.browse(cr, uid, ids, context=context): 
      b=phone.selection_item 
     print b 
     if context is None: 
      context = {} 
     datas['ids'] = context.get('active_ids', []) 
     datas['model'] = context.get('active_model', 'ir.ui.menu') 
     datas['value']=b 
     context.update({'names':b}) 
     return { 

     'type': 'ir.actions.report.xml', 
     'report_name': 'sales_invoice.report_mom', 
     'datas': datas, 
     'context':context} 

在報告

<p align="right"><span t-esc="o._context['names']"/></p> 
相關問題