A. Chandu A. Chandu - 11 months ago 58
Python Question

How to pass field values of custom model to Qweb report?

I have created a wizard in that i placed a many2one field [names] from another model in which report printing is enabled. What is happening here is when i select one record & clicked on print button it is printing only empty report.so is it possible to fetch the data into report over here.

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


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,

Thanks in advance

Answer Source
 class print_report(osv.TransientModel):
    'room1':fields.many2one('hotel.allroom','roomnum','Room No.')
    def print_report(self, cr, uid, ids, context=None):

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

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


the above code is working fine for me.. it takes names from ref. model and prints report Thanks