1 # -*- coding: utf-8 -*-
4 from openerp.addons.web import http
5 from openerp.addons.web.http import request
9 class website_gengo(http.Controller):
10 @http.route('/website/gengo_callback', type='http', auth='none')
11 def gengo_callback(self,**post):
12 cr, uid, context = request.cr, openerp.SUPERUSER_ID, request.context
13 translation_pool = request.registry['ir.translation']
14 if post and post.get('job'):
15 job = json.loads(post['job'])
16 tid = job.get('custom_data', False)
17 if (job.get('status') == 'approved') and tid:
18 term = translation_pool.browse(cr, uid, int(tid), context=context)
19 if term.job_id <> job.get('job_id'):
21 vals = {'state': 'translated', 'value': job.get('body_tgt')}
22 translation_pool.write(cr, uid, [int(tid)], vals, context=context)