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.
 
 
 
 
 
 

33 lines
945 B

# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from io import BytesIO
from odoo import models
import logging
_logger = logging.getLogger(__name__)
try:
import xlsxwriter
except ImportError:
_logger.debug('Can not import xlsxwriter`.')
class ReportXlsxAbstract(models.AbstractModel):
_name = 'report.report_xlsx.abstract'
def create_xlsx_report(self, docids, data):
objs = self.env[self.env.context.get('active_model')].browse(docids)
file_data = BytesIO()
workbook = xlsxwriter.Workbook(file_data, self.get_workbook_options())
self.generate_xlsx_report(workbook, data, objs)
workbook.close()
file_data.seek(0)
return file_data.read(), 'xlsx'
def get_workbook_options(self):
return {}
def generate_xlsx_report(self, workbook, data, objs):
raise NotImplementedError()