'This method tries to open a connection with Gengo. For that, it uses the Public and Private
keys that are linked to the company (given by Gengo on subscription). It returns a tuple with
* as first element: a boolean depicting if the authentication was a success or not
* as second element: the connection, if it was a success, or the error message returned by
Gengo when the connection failed.
This error message can either be displayed in the server logs (if the authentication was called
by the cron) or in a dialog box (if requested by the user), thus it\'s important to return it
translated.'

@api.model
def gengo_authentication(self):

    user = self.env.user
    if ((not user.company_id.gengo_public_key) or (not user.company_id.gengo_private_key)):
        return (False, _('Gengo    `Public    Key`    or    `Private    Key`    are    missing.    Enter    your    Gengo    authentication    parameters    under    `Settings    >    Companies    >    Gengo    Parameters`.'))
    try:
        gengo = Gengo(public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), sandbox=user.company_id.gengo_sandbox)
        gengo.getAccountStats()
        return (True, gengo)
    except Exception as e:
        _logger.exception('Gengo    connection    failed')
        return (False, (_('Gengo    connection    failed    with    this    message:\n``%s``') % e))
