Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
6706 Переглядів

Dear Odoo Programmers,

When you install Odoo V8 and try to confirm Incoming mail server (By cliciking "Test & Confirm" button, you will get following Error.

Connection test failed!

Here is what we got instead:
connect() takes at least 4 arguments (4 given).

Actully this is not Queation, but the this question is itself a solution. See solution as below,

Solution :

To solve this error, You need to put decorator @api.cr_uid_id exactly above connect method,

addons/fetchmail/fetchmail.py and in button_confirm_login method, you will find this problem.

For example,

   @api.cr_uid_id
    def connect(self, cr, uid, server_id, context=None):
        if isinstance(server_id, (list,tuple)):
            server_id = server_id[0]
        server = self.browse(cr, uid, server_id, context)
        if server.type == 'imap':
            if server.is_ssl:
                connection = IMAP4_SSL(server.server, int(server.port))
            else:
                connection = IMAP4(server.server, int(server.port))
            connection.login(server.user, server.password)
        elif server.type == 'pop':
            if server.is_ssl:
                connection = POP3_SSL(server.server, int(server.port))
            else:
                connection = POP3(server.server, int(server.port))
            #TODO: use this to remove only unread messages
            #connection.user("recent:"+server.user)
            connection.user(server.user)
            connection.pass_(server.password)
        return connection

The reason is when you  passing "id" in any method with using New API, you need to use @api.cr_uid_id as decorator in your method. If you don't want to put that decorator then simply pass id in connect method. See Bold fonts on following method.

    def button_confirm_login(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        for server in self.browse(cr, uid, ids, context=context):
            try:
                connection = server.connect(server.id)
                server.write({'state':'done'})
            except Exception, e:
                _logger.exception("Failed to connect to %s server %s.", server.type, server.name)
                raise osv.except_osv(_("Connection test failed!"), _("Here is what we got instead:\n %s.") % tools.ustr(e))
            finally:
                try:
                    if connection:
                        if server.type == 'imap':
                            connection.close()
                        elif server.type == 'pop':
                            connection.quit()
                except Exception:
                    # ignored, just a consequence of the previous exception
                    pass
        return True

Hope Odoo will modify code soon and solve this problem. :)

Hope this helps,

 

 

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
бер. 25
1409
0
січ. 25
3491
0
лист. 24
1597
1
серп. 23
14838
change password Вирішено
1
серп. 23
13496