def register_all(self, cursor):
        """
        Register all jasper report
        """
        res = super(IrActionReport, self).register_all(cursor)

        opj = os.path.join
        cursor.execute(
            "SELECT * FROM ir_act_report_xml WHERE auto=%s ORDER BY id",
            (True, ))
        result = cursor.dictfetchall()
        print "register_all" + str(result)
        svcs = netsvc.Service._services
        for r in result:
            if svcs.has_key('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'])
            elif r['report_xsl'] and r['report_xml']:
                report_rml('report.' + r['report_name'], r['model'],
                           opj('addons', r['report_xml']), r['report_xsl']
                           and opj('addons', r['report_xsl']))

        return res
Esempio n. 2
0
    def _lookup_report(self, cr, name):
        """
        Look up a report definition.
        """
        opj = os.path.join
 
        # First lookup in the deprecated place, because if the report definition
        # has not been updated, it is more likely the correct definition is there.
        # Only reports with custom parser sepcified in Python are still there.
        if 'report.' + name in openerp.report.interface.report_int._reports:
            new_report = openerp.report.interface.report_int._reports['report.' + name]
        else:
            cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s", (name,))
            r = cr.dictfetchone()
            if r:
                if r['report_type'] in ['qweb-pdf', 'qweb-html']:
                    return r['report_name']
                elif r['report_type'] == 'aeroo':
                    new_report = self.unregister_report(cr, r['report_name'])
                elif r['report_rml'] or r['report_rml_content_data']:
                    if r['parser']:
                        kwargs = {'parser': operator.attrgetter(r['parser'])(openerp.addons)}
                    else:
                        kwargs = {}
                    new_report = report_sxw('report.' + r['report_name'], r['model'],
                        opj('addons', r['report_rml'] or '/'), header=r['header'], register=False, **kwargs)
                elif r['report_xsl'] and r['report_xml']:
                    new_report = report_rml('report.' + r['report_name'], r['model'],
                        opj('addons', r['report_xml']),
                        r['report_xsl'] and opj('addons', r['report_xsl']), register=False)
                else:
                    raise Exception, "Unhandled report type: %s" % r
            else:
                raise Exception, "Required report does not exist: %s (Type: %s" % r
        return new_report
Esempio n. 3
0
 def register_all(self, cr):
     """Report registration handler that may be overridden by subclasses to
        add their own kinds of report services.
        Loads all reports with no manual loaders (auto==True) and
        registers the appropriate services to implement them.
     """
     opj = os.path.join
     cr.execute("SELECT * FROM ir_act_report_xml WHERE auto=%s ORDER BY id", (True,))
     result = cr.dictfetchall()
     svcs = netsvc.Service._services
     for r in result:
         if svcs.has_key('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'])
         if r['report_xsl']:
             report_rml('report.'+r['report_name'], r['model'],
                     opj('addons',r['report_xml']),
                     r['report_xsl'] and opj('addons',r['report_xsl']))
Esempio n. 4
0
 def register_all(self, cr):
     """Report registration handler that may be overridden by subclasses to
        add their own kinds of report services.
        Loads all reports with no manual loaders (auto==True) and
        registers the appropriate services to implement them.
     """
     opj = os.path.join
     cr.execute("SELECT * FROM ir_act_report_xml WHERE auto=%s ORDER BY id", (True,))
     result = cr.dictfetchall()
     svcs = netsvc.Service._services
     for r in result:
         if svcs.has_key('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'])
         if r['report_xsl']:
             report_rml('report.'+r['report_name'], r['model'],
                     opj('addons',r['report_xml']),
                     r['report_xsl'] and opj('addons',r['report_xsl']))
Esempio n. 5
0
    def _lookup_report(self, cr, name):
        """
        Look up a report definition.
        """
        opj = os.path.join
        # First lookup in the deprecated place, because if the report definition
        # has not been updated, it is more likely the correct definition is there.
        # Only reports with custom parser sepcified in Python are still there.
        if 'report.' + name in openerp.report.interface.report_int._reports:
            new_report = openerp.report.interface.report_int._reports['report.'
                                                                      + name]
        else:
            cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s",
                       (name, ))
            dict_report = cr.dictfetchone()
            if dict_report:
                if dict_report['report_type'] in ['qweb-pdf', 'qweb-html']:
                    return dict_report['report_name']
                elif dict_report['report_rml'] or dict_report[
                        'report_rml_content_data']:
                    if dict_report['parser']:
                        kwargs = {
                            'parser':
                            operator.attrgetter(dict_report['parser'])(
                                openerp.addons)
                        }
                    else:
                        kwargs = {}
                    new_report = swx_extend_delete_old.ExtendSwxReport(
                        'report.' + dict_report['report_name'],
                        dict_report['model'],
                        opj('addons', dict_report['report_rml'] or '/'),
                        header=dict_report['header'],
                        register=False,
                        **kwargs)
                elif dict_report['report_xsl'] and dict_report['report_xml']:
                    new_report = report_rml(
                        'report.' + dict_report['report_name'],
                        dict_report['model'],
                        opj('addons', dict_report['report_xml']),
                        dict_report['report_xsl']
                        and opj('addons', dict_report['report_xsl']),
                        register=False)
                else:
                    new_report = super(IrAction, self)._lookup_report(cr, name)
                    if not new_report:
                        raise "Unhandled report type: %s" % dict_report
            else:
                raise "Required report does not exist: %s" % name

            return new_report
Esempio n. 6
0
    def _lookup_report(self, cr, name):
        """
        Look up a report definition.
        """
        opj = os.path.join

        # First lookup in the deprecated place, because if the report definition
        # has not been updated, it is more likely the correct definition is there.
        # Only reports with custom parser sepcified in Python are still there.
        if 'report.' + name in openerp.report.interface.report_int._reports:
            new_report = openerp.report.interface.report_int._reports['report.'
                                                                      + name]
        else:
            cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s",
                       (name, ))
            r = cr.dictfetchone()
            if r:
                if r['report_type'] in ['qweb-pdf', 'qweb-html']:
                    return r['report_name']
                elif r['report_type'] == 'aeroo':
                    new_report = self.unregister_report(cr, r['report_name'])
                elif r['report_rml'] or r['report_rml_content_data']:
                    if r['parser']:
                        kwargs = {
                            'parser':
                            operator.attrgetter(r['parser'])(openerp.addons)
                        }
                    else:
                        kwargs = {}
                    new_report = report_sxw('report.' + r['report_name'],
                                            r['model'],
                                            opj('addons', r['report_rml']
                                                or '/'),
                                            header=r['header'],
                                            register=False,
                                            **kwargs)
                elif r['report_xsl'] and r['report_xml']:
                    new_report = report_rml('report.' + r['report_name'],
                                            r['model'],
                                            opj('addons', r['report_xml']),
                                            r['report_xsl']
                                            and opj('addons', r['report_xsl']),
                                            register=False)
                else:
                    raise Exception, "Unhandled report type: %s" % r
            else:
                raise Exception, "Required report does not exist: %s (Type: %s" % r

        return new_report