File: tuto_report.rst

package info (click to toggle)
python-odoorpc 0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 604 kB
  • sloc: python: 3,461; makefile: 154; sh: 36
file content (86 lines) | stat: -rw-r--r-- 4,426 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.. _tuto-download-report:

Download reports
****************

Another nice feature is the reports generation with the
:attr:`report <odoorpc.ODOO.report>` property.
The :func:`list <odoorpc.report.Report.list>` method allows you to list
all reports available on your `Odoo` server (classified by models), while the
:func:`download <odoorpc.report.Report.download>` method will
retrieve a report as a file (in PDF, HTML... depending of the report).

To list available reports grouped by models::

    >>> from pprint import pprint
    >>> pprint(odoo.report.list())
    {'account.common.journal.report': [{'name': 'Journals Audit',
                                        'report_name': 'account.report_journal',
                                        'report_type': 'qweb-pdf'}],
     'account.invoice': [{'name': 'Invoices',
                          'report_name': 'account.report_invoice_with_payments',
                          'report_type': 'qweb-pdf'},
                         {'name': 'Invoices without Payment',
                          'report_name': 'account.report_invoice',
                          'report_type': 'qweb-pdf'}],
     'account.payment': [{'name': 'Payment Receipt',
                          'report_name': 'account.report_payment_receipt',
                          'report_type': 'qweb-pdf'}],
     'ir.model': [{'name': 'Model Overview',
                   'report_name': 'base.report_irmodeloverview',
                   'report_type': 'qweb-pdf'}],
     'ir.module.module': [{'name': 'Technical guide',
                           'report_name': 'base.report_irmodulereference',
                           'report_type': 'qweb-pdf'}],
     'product.packaging': [{'name': 'Product Packaging (PDF)',
                            'report_name': 'product.report_packagingbarcode',
                            'report_type': 'qweb-pdf'}],
     'product.product': [{'name': 'Pricelist',
                          'report_name': 'product.report_pricelist',
                          'report_type': 'qweb-pdf'},
                         {'name': 'Product Barcode (PDF)',
                          'report_name': 'product.report_productbarcode',
                          'report_type': 'qweb-pdf'},
                         {'name': 'Product Label (PDF)',
                          'report_name': 'product.report_productlabel',
                          'report_type': 'qweb-pdf'}],
     'product.template': [{'name': 'Product Barcode (PDF)',
                           'report_name': 'product.report_producttemplatebarcode',
                           'report_type': 'qweb-pdf'},
                          {'name': 'Product Label (PDF)',
                           'report_name': 'product.report_producttemplatelabel',
                           'report_type': 'qweb-pdf'}],
     'purchase.order': [{'name': 'Purchase Order',
                         'report_name': 'purchase.report_purchaseorder',
                         'report_type': 'qweb-pdf'},
                        {'name': 'Request for Quotation',
                         'report_name': 'purchase.report_purchasequotation',
                         'report_type': 'qweb-pdf'}],
     'res.company': [{'name': 'Preview External Report',
                      'report_name': 'web.preview_externalreport',
                      'report_type': 'qweb-pdf'},
                     {'name': 'Preview Internal Report',
                      'report_name': 'web.preview_internalreport',
                      'report_type': 'qweb-pdf'}],
     'res.partner': [{'name': 'Aged Partner Balance',
                      'report_name': 'account.report_agedpartnerbalance',
                      'report_type': 'qweb-pdf'}],
     'sale.order': [{'name': 'PRO-FORMA Invoice',
                     'report_name': 'sale.report_saleorder_pro_forma',
                     'report_type': 'qweb-pdf'},
                    {'name': 'Quotation / Order',
                     'report_name': 'sale.report_saleorder',
                     'report_type': 'qweb-pdf'}]}

To download a report::

    >>> report = odoo.report.download('account.report_invoice', [1])

The method will return a file-like object, you will have to read its content
in order to save it on your file-system::

    >>> with open('invoice.pdf', 'wb') as report_file:
    ...     report_file.write(report.read())
    ...

:ref:`Next step: Save your credentials (session) <tuto-manage-sessions>`