hy, I want print assets to Excel report, format like this below :
which Depreciation Date Lines/date is ManyToOne with field called depreciation_line_ids,
if the Depreciation Date record just 1 data, is works, But if depreciation date many data per assets like bellow
odoo error like this
I stuck in the logic, 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:
final_data.append([
no,
data.name,
data.category_id.name,
data.date.strftime("%Y-%m-%d"),
"Trimitra Sistem Solusindo",
data.value,
data.salvage_value,
data.value_residual,
data.method_number,
data.method_period,
data.depreciation_line_ids.depreciation_date,
])
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()
How to print manyToOne items and merge cells based on total items in relations manyToOne in odoo ? I stuck in this logic, please help. Thanks !