How to use relatorio - 8 common examples

To help you get started, we’ve selected a few relatorio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machinalis / eff / eff_site / eff / views.py View on Github external
@login_required
@user_passes_test(__enough_perms, login_url='/accounts/login/')
def eff_client_report(request, client_slug):

    client = get_object_or_404(Client, slug=client_slug)
    context = __process_dates(request)
    from_date = context['from_date']
    to_date = context['to_date']

    if 'export' in request.GET:
        if request.GET['export'] == 'odt':
            if 'detailed' in request.GET:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_cliente_detallado.odt'))
                report_by_project = dict(map(lambda x: x[0], client.report(
                    from_date, to_date, True)))
                report_data = format_report_data(report_by_project, client,
                    from_date, to_date, True)
                report_data['clientname'] = client.name
                basic_generated = basic.generate(o=report_data).render()
                resp = HttpResponse(basic_generated.getvalue(),
                    mimetype='application/vnd.oasis.opendocument.text')
                cd = 'filename=billing-%s-%s-logs.odt' % (from_date.year,
                    from_date.strftime("%m"), )
                resp['Content-Disposition'] = cd
                return resp
            else:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_cliente.odt'))
github hugsy / stuff / unmap.py View on Github external
def export(self):
        tab = self.sort_data()

        try :
            relatorio =  sys.modules['relatorio']
            template = relatorio.templates.opendocument.Template(source=None, filepath=self.template)
            data = template.generate(o=tab).render().getvalue()

            if len(tab['lines']) > 0:
                with open(self.filename,'w') as fd:
                    fd.write(data)
                    if self.verbose:
                        self.logger.info ("MD5: %s" % md5(data).hexdigest())

        except Exception, e:
            self.logger.error("export failed : %s" % e)
github machinalis / eff / eff_site / eff / views.py View on Github external
'city': client.city or '',
                           'state_and_country': state_and_country,
                           'currency': client.currency.ccy_symbol or \
                               client.currency.ccy_code,
                           }
            today = datetime.now()
            reverse_billing = FixedPriceClientReverseBilling(
                project_data={'name': project.name,
                              'price': str(project.fixed_price)},
                client_data=client_data,
                today=today.strftime("%A, %d %B %Y"),
                reference="%s%s%s" % (client.name.lower(), today.year,
                    today.strftime("%m"))
                )

            basic = Template(source=None, filepath=os.path.join(cur_dir,
                '../templates/reporte_cliente_precio_fijo.odt'))
            basic_generated = basic.generate(o=reverse_billing).render()
            resp = HttpResponse(basic_generated.getvalue(),
                mimetype='application/vnd.oasis.opendocument.text')
            cd = 'filename=billing-%s.odt' % project.external_id
            resp['Content-Disposition'] = cd
            return resp

        return render_to_response('admin_reportes_cliente_costo_fijo.html',
            context)
    else:
        client_id = request.POST['client']
        client = get_object_or_404(Client, id=client_id)
        projects = Project.objects.filter(client=client, billing_type='FIXED')
        ret = '<option value="" selected="selected">----</option>'
        ret += ''.join(['<option value="%s">%s</option>' % (p.id, p.name) \
github machinalis / eff / eff_site / eff / views.py View on Github external
from_date = context['from_date']
    to_date = context['to_date']
    user = User.objects.get(username=user_name)

    project = None
    if 'project' in request.GET:
        project = request.GET['project']
        context['project'] = project

    # detailed log report
    context['report'] = user.get_profile().report(from_date, to_date, project)

    if 'export' in request.GET:
        if request.GET['export'] == 'odt':
            if 'detailed' in request.GET:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_usuario_detallado.odt'))
                report_data = format_report_data_user(context['report'], user,
                    from_date, to_date, True)
                basic_generated = basic.generate(o=report_data).render()
                resp = HttpResponse(basic_generated.getvalue(),
                    mimetype='application/vnd.oasis.opendocument.text')
                cd = 'filename=reverse_billing-%s-%s-logs.odt' % (
                    from_date.year, from_date.strftime("%m"), )
                resp['Content-Disposition'] = cd
                return resp
            else:
                basic = Template(source=None, filepath=os.path.join(cur_dir,
                    '../templates/reporte_usuario.odt'))
                report_by_project = list(TimeLog.get_summary_per_project(
                    user.get_profile(), from_date, to_date, True))
                report_by_project.sort(cmp=lambda (x0, x1, x2, x3, x4),
github tryton / trytond / trytond / ir / translation.py View on Github external
keywords=None, comment_tags=None, **options):
            options['template_class'] = template_class
            content = BytesIO(content)
            if keywords is None:
                keywords = []
            if comment_tags is None:
                comment_tags = []

            for _, _, string, _ in genshi_extract(
                    content, keywords, comment_tags, options):
                if string:
                    yield string
        if not template_class:
            raise ValueError('a template class is required')
        return method
    factories = MIMETemplateLoader().factories
    extract_report_txt = extract_report_genshi(factories['text'])
    extract_report_xml = extract_report_genshi(
        factories.get('markup', factories.get('xml')))
    extract_report_html = extract_report_genshi(
        factories.get('markup', factories.get('xml')))
    extract_report_xhtml = extract_report_genshi(
        factories.get('markup', factories.get('xml')))
    del factories

    def set_report(self):
        pool = Pool()
        Report = pool.get('ir.action.report')
        Translation = pool.get('ir.translation')

        if self.model == Report:
            reports = self.records
github tryton / trytond / trytond / report / report.py View on Github external
def render(cls, report, report_context):
        "calls the underlying templating engine to renders the report"
        fd, path = cls._prepare_template_file(report)

        mimetype = MIMETYPES[report.template_extension]
        rel_report = relatorio.reporting.Report(path, mimetype,
                ReportFactory(), relatorio.reporting.MIMETemplateLoader())
        if report.translatable:
            cls._add_translation_hook(rel_report, report_context)
        else:
            report_context['set_lang'] = lambda language: None

        data = rel_report(**report_context).render()
        if hasattr(data, 'getvalue'):
            data = data.getvalue()
        os.close(fd)
        os.remove(path)

        return data
github tryton / trytond / trytond / report / report.py View on Github external
def render(cls, report, report_context):
        "calls the underlying templating engine to renders the report"
        fd, path = cls._prepare_template_file(report)

        mimetype = MIMETYPES[report.template_extension]
        rel_report = relatorio.reporting.Report(path, mimetype,
                ReportFactory(), relatorio.reporting.MIMETemplateLoader())
        if report.translatable:
            cls._add_translation_hook(rel_report, report_context)
        else:
            report_context['set_lang'] = lambda language: None

        data = rel_report(**report_context).render()
        if hasattr(data, 'getvalue'):
            data = data.getvalue()
        os.close(fd)
        os.remove(path)

        return data
github tryton / trytond / trytond / ir / translation.py View on Github external
and node.parentNode.tagName in {
                            'text:placeholder',
                            'text:page-number',
                            'text:page-count',
                            }):
                    return
                if node.nodeValue:
                    txt = node.nodeValue.strip()
                    if txt:
                        yield txt

            for child in [x for x in node.childNodes]:
                for string in extract(child):
                    yield string

        zip_ = get_zip_file(BytesIO(content))
        for content_xml in [
                zip_.read('content.xml'),
                zip_.read('styles.xml'),
                ]:
            document = xml.dom.minidom.parseString(content_xml)
            for string in extract(document.documentElement):
                yield string

relatorio

A templating library able to output odt and pdf files

GPL-3.0
Latest version published 7 days ago

Package Health Score

64 / 100
Full package analysis

Similar packages