在 odoo 9 中显示 excel sheet
displaying excel sheet in odoo 9
如何在 odoo 9.0 中以 excel 格式显示多条记录的报告?
在下面的代码中,它只显示一条记录,但我想显示多条记录。
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>
所以,我能解决这个问题吗?我可以就这个问题寻求帮助吗?``
您的代码在 excel sheet
的相同位置循环写入
尝试
对于索引,枚举中的行(obj.timesheet_ids):
sheet.write(索引,2,line.date)
...
或
for index, obj in enumerate(partners):
sheet = workbook.add_worksheet("timesheet"+str(索引))
如何在 odoo 9.0 中以 excel 格式显示多条记录的报告?
在下面的代码中,它只显示一条记录,但我想显示多条记录。 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>
所以,我能解决这个问题吗?我可以就这个问题寻求帮助吗?``
您的代码在 excel sheet
的相同位置循环写入尝试
对于索引,枚举中的行(obj.timesheet_ids):
sheet.write(索引,2,line.date)
...
或
for index, obj in enumerate(partners): sheet = workbook.add_worksheet("timesheet"+str(索引))