[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
This commit is contained in:
parent
488111719c
commit
1ccbc213e7
|
@ -48,8 +48,11 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
('receive', 'Receive Translation'),
|
('receive', 'Receive Translation'),
|
||||||
('both', 'Both')], "Sync Type"),
|
('both', 'Both')], "Sync Type"),
|
||||||
'lang_id': fields.many2one('res.lang', 'Language', required=True),
|
'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):
|
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
|
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 = context.copy()
|
||||||
ctx['gengo_language'] = wizard.lang_id.id
|
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']:
|
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']:
|
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'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None):
|
def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None):
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
<field name="lang_id"/>
|
<field name="lang_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="sync_type" widget="radio"/>
|
<group>
|
||||||
|
<field name="sync_type" widget="radio"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="sync_limit" required="1"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
from openerp.addons.web import http
|
from openerp.addons.web import http
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
|
|
||||||
|
GENGO_DEFAULT_LIMIT = 20
|
||||||
|
|
||||||
class website_gengo(http.Controller):
|
class website_gengo(http.Controller):
|
||||||
|
|
||||||
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
|
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
|
||||||
|
@ -27,3 +30,8 @@ class website_gengo(http.Controller):
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
request.registry['res.company'].write(request.cr, request.uid, user.company_id.id,config)
|
request.registry['res.company'].write(request.cr, request.uid, user.company_id.id,config)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
|
||||||
|
def set_gengo_config(self):
|
||||||
|
request.registry['base.gengo.translations']._sync_request(request.cr, request.uid, limit=GENGO_DEFAULT_LIMIT, context=request.context)
|
||||||
|
return True
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
$('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo');
|
$('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo');
|
||||||
self.$el.find('.gengo_wait').addClass("hidden");
|
self.$el.find('.gengo_wait').addClass("hidden");
|
||||||
self.$el.find('.gengo_inprogress,.gengo_discard').removeClass("hidden");
|
self.$el.find('.gengo_inprogress,.gengo_discard').removeClass("hidden");
|
||||||
|
openerp.jsonRpc('/website/post_gengo_jobs', 'call', {});
|
||||||
self.save();
|
self.save();
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert("Could not Post translation");
|
alert("Could not Post translation");
|
||||||
|
|
Loading…
Reference in New Issue