From 1ccbc213e7f39c1902d70714d0e75418155dab6d Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Fri, 28 Mar 2014 17:07:15 +0530 Subject: [PATCH] [IMP] limit option in gengo manual request instead of20 reqests every time, post jobs on gengo at the time of website post without compromise speed bzr revid: pga@tinyerp.com-20140328113715-5y14vtgcfnojk7bs --- addons/base_gengo/wizard/base_gengo_translations.py | 11 ++++++++--- .../wizard/base_gengo_translations_view.xml | 7 ++++++- addons/website_gengo/controllers/main.py | 8 ++++++++ addons/website_gengo/static/src/js/website_gengo.js | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index 79e3897e264..dcf6e34c397 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -48,8 +48,11 @@ class base_gengo_translations(osv.osv_memory): ('receive', 'Receive Translation'), ('both', 'Both')], "Sync Type"), 'lang_id': fields.many2one('res.lang', 'Language', required=True), + 'sync_limit': fields.integer("No. of terms to sync"), } - _defaults = {'sync_type' : 'both'} + _defaults = {'sync_type' : 'both', + 'sync_limit' : 20 + } def gengo_authentication(self, cr, uid, context=None): ''' This method tries to open a connection with Gengo. For that, it uses the Public and Private @@ -94,10 +97,12 @@ class base_gengo_translations(osv.osv_memory): ctx = context.copy() ctx['gengo_language'] = wizard.lang_id.id + if wizard.sync_limit > 200 or wizard.sync_limit < 1: + raise osv.except_osv(_("Warning"), _('Sync limit should between 1 to 200 for Gengo translation services.')) if wizard.sync_type in ['send','both']: - self._sync_request(cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx) + self._sync_request(cr, uid, wizard.sync_limit, context=ctx) if wizard.sync_type in ['receive','both']: - self._sync_response( cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx) + self._sync_response( cr, uid, wizard.sync_limit, context=ctx) return {'type': 'ir.actions.act_window_close'} def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None): diff --git a/addons/base_gengo/wizard/base_gengo_translations_view.xml b/addons/base_gengo/wizard/base_gengo_translations_view.xml index f4fed7e5ddd..f1d77730c47 100644 --- a/addons/base_gengo/wizard/base_gengo_translations_view.xml +++ b/addons/base_gengo/wizard/base_gengo_translations_view.xml @@ -10,7 +10,12 @@ - + + + + + +