def render_to_file(self, cursor, uid, fids, report, dirname, file_name, context=None): """Return a tuple of status (True: OK, False: Failed) and the invoice path. """ if context is None: context = {} try: report = netsvc.service_exist(report) values = { 'model': 'giscedata.facturacio.factura', 'id': fids, 'report_type': 'pdf' } content = report.create(cursor, uid, fids, values, context)[0] # Escriure report a "fitxer" fitxer_name = os.path.join(dirname, file_name) with open(fitxer_name, 'wb') as f: f.write(content) return True, fids except Exception: import traceback traceback.print_exc() sentry = self.pool.get('sentry.setup') if sentry is not None: sentry.client.captureException() return False, fids
def register_jasper_report(name, model): name = 'report.%s' % name # Register only if it didn't exist another "jasper_report" with the same name # given that developers might prefer/need to register the reports themselves. # For example, if they need their own parser. if netsvc.service_exist( name ): if isinstance( netsvc.SERVICES[name], report_jasper ): return del netsvc.SERVICES[name] report_jasper( name, model )
def register_jasper_report(name, model): name = 'report.%s' % name # Register only if it didn't exist another "jasper_report" with the same name # given that developers might prefer/need to register the reports themselves. # For example, if they need their own parser. if netsvc.service_exist(name): if isinstance(netsvc.SERVICES[name], report_jasper): return del netsvc.SERVICES[name] report_jasper(name, model)
def register_report_sxw_ext(name, model,tmpl_path,parser=rml_parse): """ Registers a report to use the OpenOffice reporting engine. """ name = 'report.%s' % name # Register only if it didn't exist another report with the same name # given that developers might prefer/need to register the reports themselves. # For example, if they need their own parser. if netsvc.service_exist( name ): if isinstance( netsvc.SERVICES[name], report_sxw_ext): return del netsvc.SERVICES[name] report_sxw_ext( name, model,tmpl_path,parser=parser)
def register_all(self, cr): opj = os.path.join result='' cr.execute("SELECT * FROM ir_act_report_xml WHERE model=%s \ ORDER BY id", ('dm.offer.document',)) result = cr.dictfetchall() for r in result: if netsvc.service_exist('report.'+r['report_name']): continue if r['report_rml'] or r['report_rml_content_data']: report_sxw('report.'+r['report_name'], r['model'], opj('addons',r['report_rml'] or '/'), header=r['header'], parser=offer_document) super(report_xml, self).register_all(cr)
def register_all(self, cr): opj = os.path.join result = '' cr.execute( "SELECT * FROM ir_act_report_xml WHERE model=%s \ ORDER BY id", ('dm.offer.document', )) result = cr.dictfetchall() for r in result: if netsvc.service_exist('report.' + r['report_name']): continue if r['report_rml'] or r['report_rml_content_data']: report_sxw('report.' + r['report_name'], r['model'], opj('addons', r['report_rml'] or '/'), header=r['header'], parser=offer_document) super(report_xml, self).register_all(cr)