OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.3 KiB

  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. ===============
  5. Base report csv
  6. ===============
  7. This module provides a basic report class to generate csv report.
  8. Usage
  9. =====
  10. An example of CSV report for partners on a module called `module_name`:
  11. A python class ::
  12. from odoo import models
  13. class PartnerCSV(models.AbstractModel):
  14. _name = 'report.report_csv.partner_csv'
  15. _inherit = 'report.report_csv.abstract'
  16. def generate_csv_report(self, writer, data, partners):
  17. writer.writeheader()
  18. for obj in partners:
  19. writer.writerow({
  20. 'name': obj.name,
  21. 'email': obj.email,
  22. })
  23. def csv_report_options(self):
  24. res = super().csv_report_options()
  25. res['fieldnames'].append('name')
  26. res['fieldnames'].append('email')
  27. res['delimiter'] = ';'
  28. res['quoting'] = csv.QUOTE_ALL
  29. return res
  30. A report XML record ::
  31. <report
  32. id="partner_csv"
  33. model="res.partner"
  34. string="Print to CSV"
  35. report_type="csv"
  36. name="module_name.report_name"
  37. file="res_partner"
  38. attachment_use="False"
  39. />
  40. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  41. :alt: Try me on Runbot
  42. :target: https://runbot.odoo-community.org/runbot/143/11.0
  43. Bug Tracker
  44. ===========
  45. Bugs are tracked on `GitHub Issues
  46. <https://github.com/OCA/reporting-engine/issues>`_. In case of trouble, please
  47. check there if your issue has already been reported. If you spotted it first,
  48. help us smashing it by providing a detailed and welcomed feedback.
  49. Credits
  50. =======
  51. Contributors
  52. ------------
  53. * Enric Tobella <etobella@creublanca.es>
  54. Maintainer
  55. ----------
  56. .. image:: https://odoo-community.org/logo.png
  57. :alt: Odoo Community Association
  58. :target: https://odoo-community.org
  59. This module is maintained by the OCA.
  60. OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
  61. To contribute to this module, please visit https://odoo-community.org.