| [57] | 1 | from cStringIO import StringIO |
|---|
| 2 | from common import Invoice, repos, inv |
|---|
| [58] | 3 | import demo_chart |
|---|
| [57] | 4 | |
|---|
| 5 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.text', |
|---|
| 6 | 'basic.odt', report_name='basic') |
|---|
| 7 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.text', |
|---|
| 8 | 'invoice.odt', report_name='complicated') |
|---|
| 9 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.spreadsheet', |
|---|
| 10 | 'pivot.ods', report_name='pivot') |
|---|
| 11 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.presentation', |
|---|
| 12 | 'presentation.odp', report_name='presentation') |
|---|
| 13 | |
|---|
| [58] | 14 | if __name__ == '__main__': |
|---|
| 15 | # Add a chart to the invoice |
|---|
| 16 | inv['chart'] = repos.reports[Invoice]['pie'] |
|---|
| [57] | 17 | |
|---|
| [58] | 18 | # ODT |
|---|
| 19 | basic_report, _ = repos.reports[Invoice]['basic'] |
|---|
| [74] | 20 | file('bonham_basic.odt', 'wb').write(basic_report(o=inv).render().getvalue()) |
|---|
| [58] | 21 | report, _ = repos.reports[Invoice]['complicated'] |
|---|
| [74] | 22 | file('bonham_complicated.odt', 'wb').write(report(o=inv).render().getvalue()) |
|---|
| [57] | 23 | |
|---|
| [58] | 24 | # ODS |
|---|
| 25 | ods_report, _ = repos.reports[Invoice]['pivot'] |
|---|
| [74] | 26 | file('bonham_pivot.ods', 'wb').write(ods_report(o=inv).render().getvalue()) |
|---|
| [58] | 27 | |
|---|
| 28 | # ODP |
|---|
| 29 | odp_report, _ = repos.reports[Invoice]['presentation'] |
|---|
| [74] | 30 | file('bonham_presentation.odp', 'wb').write(odp_report(o=inv).render().getvalue()) |
|---|