[FIX] base_gengo: do not crash if Gengo is not present
Before this commit, calling gengo_authentication (executed from the cron _send_translation_terms) returns an error when the python library gengo is not found on the system. If tried to request a synchronisation, got an error "NameError: name 'Gengo' is not defined" Gengo variable was undefined as no imported. closes odoo/odoo#40686 X-original-commit: 675b355954522caf7d72ab20cc431d19c5a05a8f Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server saas~12.5\n"
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-08-26 08:16+0000\n"
|
||||
"PO-Revision-Date: 2019-08-26 08:16+0000\n"
|
||||
"POT-Creation-Date: 2019-11-22 08:19+0000\n"
|
||||
"PO-Revision-Date: 2019-11-22 08:19+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -179,6 +179,13 @@ msgid ""
|
||||
"``%s``"
|
||||
msgstr ""
|
||||
|
||||
#. module: base_gengo
|
||||
#: code:addons/base_gengo/wizard/base_gengo_translations.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Gengo library not installed. Contact your system administrator to use it."
|
||||
msgstr ""
|
||||
|
||||
#. module: base_gengo
|
||||
#: model:ir.actions.act_window,name:base_gengo.action_wizard_base_gengo_translations
|
||||
#: model:ir.ui.menu,name:base_gengo.menu_action_wizard_base_gengo_translations
|
||||
|
||||
@@ -15,6 +15,7 @@ _logger = logging.getLogger(__name__)
|
||||
try:
|
||||
from gengo import Gengo
|
||||
except ImportError:
|
||||
Gengo = None
|
||||
_logger.warning('Gengo library not found, Gengo features disabled. If you plan to use it, please install the gengo library from http://pypi.python.org/pypi/gengo')
|
||||
|
||||
GENGO_DEFAULT_LIMIT = 20
|
||||
@@ -78,6 +79,8 @@ class BaseGengoTranslations(models.TransientModel):
|
||||
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`."))
|
||||
if not Gengo:
|
||||
return (False, _("Gengo library not installed. Contact your system administrator to use it."))
|
||||
try:
|
||||
gengo = Gengo(
|
||||
public_key=user.company_id.gengo_public_key.encode('ascii'),
|
||||
|
||||
Reference in New Issue
Block a user