v 14.0 Third Party 36
Download for v 14.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 223
Technical Name base_report_csv
Websitehttp://mervatmosaad96@gmail.com
You bought this module and need support? Click here!

Base report csv

Usage

An example of CSV report for partners on a module called module_name:

A python class

from odoo import models

class PartnerCSV(models.AbstractModel):
    _name = 'report.base_report_csv.partner_csv'
    _inherit = 'report.base_report_csv.abstract'

    def generate_csv_report(self, writer, data, partners):
        writer.writeheader()
        for obj in partners:
            writer.writerow({
                'name': obj.name,
                'email': obj.email,
            })

    def csv_report_options(self):
        res = super().csv_report_options()
        res['fieldnames'].append('name')
        res['fieldnames'].append('email')
        res['delimiter'] = ';'
        res['quoting'] = csv.QUOTE_ALL
        return res

A report XML record

<report
    id="partner_csv"
    model="res.partner"
    string="Print to CSV"
    report_type="csv"
    name="module_name.report_name"
    file="res_partner"
    attachment_use="False"
/>

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.