Exemplo n.º 1
0
 def get_docs_conn(self, cr):
     pool = registry(cr.dbname)
     icp = pool.get('ir.config_parameter')
     docs_host = icp.get_param(cr, 1, 'aeroo.docs_host') or 'localhost'
     docs_port = icp.get_param(cr, 1, 'aeroo.docs_port') or '8989'
     docs_auth_type = icp.get_param(cr, 1, 'aeroo.docs_auth_type') or False
     docs_username = icp.get_param(cr, 1, 'aeroo.docs_username') or 'anonymous'
     docs_password = icp.get_param(cr, 1, 'aeroo.docs_password') or 'anonymous'
     docs_client = DOCSConnection(docs_host, docs_port, username=docs_username, password=docs_password)
     return docs_client
Exemplo n.º 2
0
    def check(self):
        icp = self.env['ir.config_parameter']
        icp.set_param('aeroo.docs_enabled', str(self.enabled))
        icp.set_param('aeroo.docs_host', self.host)
        icp.set_param('aeroo.docs_port', self.port)
        icp.set_param('aeroo.docs_auth_type', self.auth_type or 'simple')
        icp.set_param('aeroo.docs_username', self.username)
        icp.set_param('aeroo.docs_password', self.password)
        error_details = ''
        state = 'done'

        if self.enabled:
            try:
                fp = tools.file_open('report_aeroo/test_temp.odt', mode='rb')
                file_data = fp.read()
                with aeroo_lock:
                    docs_client = DOCSConnection(self.host,
                                                 self.port,
                                                 username=self.username,
                                                 password=self.password)
                    token = docs_client.upload(file_data)
                    data = docs_client.convert(identifier=token,
                                               out_mime='pdf')
            except Exception as e:
                error_details = str(e)
                state = 'error'
        if state == 'error':
            msg = _(
                'Failure! Connection to DOCS service was not established ' +
                'or convertion to PDF unsuccessful!')
        elif state == 'done' and not self.enabled:
            msg = _('Connection to Aeroo DOCS disabled!')
        else:
            msg = _(
                'Success! Connection to the DOCS service was successfully ' +
                'established and PDF convertion is working.')
        self.msg = msg
        self.error_details = error_details
        self.state = state
        mod_obj = self.env['ir.model.data']
        act_obj = self.env['ir.actions.act_window']
        result = mod_obj.get_object_reference('report_aeroo',
                                              'action_docs_config_wizard')
        act_id = result and result[1] or False
        result = act_obj.search([('id', '=', act_id)]).read()[0]
        result['res_id'] = self.id
        return result