2017-06-22 130 views
0

如何以excel格式顯示odoo 9.0中多個記錄的報告?在odoo中顯示excel表格9

在下面的代碼中,它只顯示一條記錄,但我想顯示多條記錄。 Python代碼: -

def generate_xlsx_report(self, workbook, data, partners): 
     for obj in partners: 
        sheet = workbook.add_worksheet("timesheet") 
        bold = workbook.add_format({'bold': True}) 
        sheet.write(1,1, obj.employee_id.name) 
     for line in obj.timesheet_ids: 

           bold = workbook.add_format({'bold': True}) 
           sheet.write(1,2, line.date) 
           sheet.write(1,3, line.account_id.name) 
           sheet.write(1,4 , line.name) 
           sheet.write(1,5, line.unit_amount) 
XML code:- 

<data> 
<openerp> 

<report 
    id="partner_xlsx" 
    model="hr_timesheet_sheet.sheet" 
    string="Timesheet Report" 
    report_type="xlsx" 
    name="hr_timesheet_sheet.sheet.xlsx" 
    file="hr_timesheet_sheet.sheet.xlsx" 
    attachment_use="False" 
/> 
</openerp> 
</data> 

所以,我可以解決這個問題。我可以得到一些幫助在此問題,請``

回答

0

你的代碼在一個循環中寫上的Excel工作表的同一位置

嘗試
索引,在枚舉線(obj.timesheet_ids): sheet.write(指數,2,line.date) ...

索引,OBJ在枚舉(夥伴): 片= workbook.add_worksheet( 「時間表」 + STR(指數) )