Odoo Help


How to redefine a method of controller Odoo

on 12/3/14, 11:01 AM 1,252 views

Can someone help me. I would just change the definition of a method of controllers website module. here is my code

import datetime
from itertools import islice
import json
import xml.etree.ElementTree as ET

import logging
import re

import werkzeug.utils
import urllib2
import werkzeug.wrappers
from PIL import Image

import openerp
from openerp.addons.web import http
from openerp.http import request, STATIC_CACHE
from openerp.tools import image_save_for_web
import openerp.addons.website.controllers.main as main

logger = logging.getLogger(__name__)
# Completely arbitrary limits
SITEMAP_CACHE_TIME = datetime.timedelta(hours=12)

class Website_extend(main.Website):
     @http.route(['/website/seo_suggest/<keywords>'], type='http', auth="public", website=True)
     def seo_suggest(self, keywords):
         url = "http://google.com/complete/search?hl=fr"
             req = urllib2.Request("%s&%s" % (url, werkzeug.url_encode({
                 'ie': 'utf8', 'oe': 'utf8', 'output': 'toolbar', 'q': keywords})))
             request = urllib2.urlopen(req)
         except (urllib2.HTTPError, urllib2.URLError):
             return []
         xmlroot = ET.fromstring(request.read())
         return json.dumps([sugg[0].attrib['data'] for sugg in xmlroot if len(sugg) and sugg[0].attrib['data']])   

@tansadio, I'm also interested in achieving this. I'll write back if I find a solution. Please post back here if you find a solution as well.

Luke Branch
on 12/4/14, 5:46 AM

it works well on localhost but on the server it takes me an error like: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 224: ordinal not in range

on 12/4/14, 7:21 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 12/3/14, 11:01 AM
Seen: 1252 times
Last updated: 3/16/15, 8:10 AM