Hy , I want to print odoo in XLSX, this is my code:
def generate_xlsx_report(self, workbook, data, lines):
format = workbook.add_format({'font_size' : 12, 'align': 'center', 'bold' : True})
format1 = workbook.add_format({'font_size': 12, 'align': 'center', 'bold': False})
sheet = workbook.add_worksheet("Assets")
sheet.set_row(0, 24)
sheet.set_column('A1:O1', 20)
headers = [
"No",
"Asset Name",
"Category",
"Date",
"Partners",
"Gros Value",
"Residual Value",
"Value",
"Number Of Depreciations",
"Number of Month in a Period"
"Depre Date",
]
column = 0
row = 0
for col in headers:
sheet.write(row, column, col, format)
column += 1
row = 1
final_data = []
no = 1
for data in lines:
for datas in data:
for depre in datas.depreciation_line_ids:
final_data.append([
no,
datas.name,
datas.category_id.name,
datas.date.strftime("%Y-%m-%d"),
"Maju mundur",
datas.value,
datas.salvage_value,
datas.value_residual,
datas.method_number,
datas.method_period,
depre.depreciation_date.strftime("%Y-%m-%d"),
])
no += 1
for data in final_data:
column = 0
for col in data:
sheet.write(row, column, col,format1)
column += 1
row += 1
workbook.close()
And this is my expecation output
Each assets have many depreciation, but when I print assets, output like below :
How to just return each assets ( no duplicate) , look , Asset Name, Category and Date is duplicate data, even tough is just 1 data , how to print output each assets and have many depreciation date?
Thanks