Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
620 views
in Technique[技术] by (71.8m points)

xlsxwriter - How to Print Many to one deppends total value in odoo xlsx writer

hy, I want print assets to Excel report, format like this below :

enter image description here

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

enter image description here

odoo error like this

enter image description here

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 !

question from:https://stackoverflow.com/questions/65660432/how-to-print-many-to-one-deppends-total-value-in-odoo-xlsx-writer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...