Search code examples
pythonjasper-reportsodoo-9

Odoo - Print multiple jasper reports from tree view


In Odoo (v9), when I print a report of an individual customer invoice, jasper report works fine. But when I try to print reports of multiple number of customer invoices from the tree view, I get singleton error. Is there something else to be done in ireport for solving this?


Solution

  • Report group is used for solving this. In the .py file of jasper report:

    • Pass the field by which we want to "group", via the dictionary vals{ }, along with other fields. I used group by "invoice_id".

      vals = {'invoice_id' : invoice.id}
      
    • Sort the result by "invoice_id" after appending the dictionary.

      result.append(vals)
      result = sorted(result, key=lambda d: (d['invoice_id']))   
      return result
      

    In ireport:

    • Right click on the file name inside ireport
    • Add Report Group
    • Give a Group name
    • Group by following report object: "invoice_id"
    • Add a group header and group footer
    • Set the properties of group header as: start on a new page
    • Compile