OpenSur / Odoo_addons

Odoo addons published
23 stars 40 forks source link

website_lang_flag generates internal server error #29

Open vanhirtum-mm opened 9 years ago

vanhirtum-mm commented 9 years ago

After installing the website_language_flags module and using it with a number of languages added, odoo generates an internal server error.

This seems to be related to the fact that there is some code changed in odoo after the website_language_flags module was last released.

I added an ir_http.py file with following code to the module and this resolves the internal server error.


import openerp

from openerp.osv import orm, osv, fields from openerp.http import request

class ir_http(orm.AbstractModel): _inherit="ir.http"

def get_nearest_lang(self, lang):
    # Try to find a similar lang. Eg: fr_BE and fr_FR
    if lang in request.website.get_languages():
        return lang

    short = lang.split('_')[0]
    for code, name, lang_obj in request.website.get_languages():
        if code.startswith(short):
            return code
    return False

ir_http()


mrawi commented 9 years ago

I confirm this, though worked fine on one instance but not on two others. Here's the log:

2015-06-30 20:30:08,027 8277 ERROR flags werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/opt/test/odoo/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/opt/test/odoo/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/opt/test/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/test/odoo/openerp/http.py", line 1289, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/test/odoo/openerp/http.py", line 1263, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
    return self.app(environ, start_response)
  File "/opt/test/odoo/openerp/http.py", line 1263, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
    return self.app(environ, start_response)
  File "/opt/test/odoo/openerp/http.py", line 1434, in dispatch
    result = ir_http._dispatch()
  File "/opt/test/odoo/addons/website_rtl/models/ir_http.py", line 31, in _dispatch
    resp = super(ir_http, self)._dispatch()
  File "/opt/test/odoo/addons/crm/ir_http.py", line 13, in _dispatch
    response = super(ir_http, self)._dispatch()
  File "/opt/test/odoo/addons/website/models/ir_http.py", line 118, in _dispatch
    nearest_lang = not func and self.get_nearest_lang(path[1])
File "/opt/test/odoo/addons/website/models/ir_http.py", line 62, in get_nearest_lang
    for code, name in request.website.get_languages():
ValueError: too many values to unpack
akram1 commented 9 years ago

Same problem on Odoo 8 (build 26/7/2015) Ubuntu 14.04, Postgres 9.4.1, werkzeug 0.9.6, Python 2.7.8

I tested this module back in April It was working now it is not

Aivenho commented 8 years ago

Traceback (most recent call last): File "/opt/odoo/odoo/addons/website/models/ir_http.py", line 199, in _handle_exception response = super(ir_http, self)._handle_exception(exception) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_http.py", line 145, in _handle_exception return request._handle_exception(exception) File "/opt/odoo/odoo/openerp/http.py", line 666, in _handle_exception return super(HttpRequest, self)._handle_exception(exception) File "/opt/odoo/odoo/openerp/http.py", line 1370, in get_response result.flatten() File "/opt/odoo/odoo/openerp/http.py", line 1241, in flatten self.response.append(self.render()) File "/opt/odoo/odoo/openerp/http.py", line 1235, in render context=request.context) File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/opt/odoo/odoo/addons/website/models/ir_ui_view.py", line 173, in render return super(view, self).render(cr, uid, id_or_xml_id, values=values, engine=engine, context=context) File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_ui_view.py", line 1022, in render return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context) File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 263, in render return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 447, in render_tag_call return self.render(cr, uid, template, d) File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 263, in render return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 433, in render_tag_if return self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 424, in render_tag_foreach ru.append(self.render_element(element, template_attributes, generated_attributes, copy_qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 433, in render_tag_if return self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 285, in render_node for att, val in attrs: File "/opt/odoo/odoo/addons/website/models/ir_qweb.py", line 61, in render_att_att for att, val in super(QWeb, self).render_att_att(element, attribute_name, attribute_value, qwebcontext): File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 359, in render_att_att return [(attribute_name[6:], self.eval(attribute_value, qwebcontext))] File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 207, in eval raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 204, in eval return qwebcontext.safe_eval(expr) File "/opt/odoo/odoo/openerp/addons/base/ir/ir_qweb.py", line 89, in safe_eval return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True) File "/opt/odoo/odoo/openerp/tools/safe_eval.py", line 314, in safe_eval return eval(c, globals_dict, locals_dict) File "", line 1, in QWebException: "tuple index out of range" while evaluating "website.image_url(lg[2], 'flag_image')"

mcassuto commented 8 years ago

Same issue here the ir_http.py fix above does not fix the issue.

Trace: ERROR test openerp.addons.website.models.ir_http: 500 Internal Server Error:

Traceback (most recent call last): File "/home/odoo8dev/git/odoo/addons/website/models/ir_http.py", line 199, in _handle_exception response = super(ir_http, self)._handle_exception(exception) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_http.py", line 145, in _handle_exception return request._handle_exception(exception) File "/home/odoo8dev/git/odoo/openerp/http.py", line 668, in _handle_exception return super(HttpRequest, self)._handle_exception(exception) File "/home/odoo8dev/git/odoo/openerp/http.py", line 1372, in get_response result.flatten() File "/home/odoo8dev/git/odoo/openerp/http.py", line 1243, in flatten self.response.append(self.render()) File "/home/odoo8dev/git/odoo/openerp/http.py", line 1237, in render context=request.context) File "/home/odoo8dev/git/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/addons/website/models/ir_ui_view.py", line 173, in render return super(view, self).render(cr, uid, id_or_xml_id, values=values, engine=engine, context=context) File "/home/odoo8dev/git/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_ui_view.py", line 1022, in render return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context) File "/home/odoo8dev/git/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/openerp/api.py", line 372, in old_api result = method(recs, _args, _kwargs) File "/home/odoo8dev/git/client/addons/report_custom_header/models/ir_qweb.py", line 20, in render id_or_xml_id, qwebcontext=qwebcontext, loader=loader File "/home/odoo8dev/git/odoo/openerp/api.py", line 266, in wrapper return new_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/openerp/api.py", line 508, in new_api result = method(self._model, cr, uid, _args, _old_kwargs) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 263, in render return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 447, in render_tag_call return self.render(cr, uid, template, d) File "/home/odoo8dev/git/odoo/openerp/api.py", line 268, in wrapper return old_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/openerp/api.py", line 372, in old_api result = method(recs, _args, _kwargs) File "/home/odoo8dev/git/client/addons/report_custom_header/models/ir_qweb.py", line 20, in render id_or_xml_id, qwebcontext=qwebcontext, loader=loader File "/home/odoo8dev/git/odoo/openerp/api.py", line 266, in wrapper return new_api(self, _args, _kwargs) File "/home/odoo8dev/git/odoo/openerp/api.py", line 508, in new_api result = method(self._model, cr, uid, _args, _old_kwargs) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 263, in render return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 433, in render_tag_if return self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 302, in render_node result = self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 424, in render_tag_foreach ru.append(self.render_element(element, template_attributes, generated_attributes, copy_qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 300, in render_node result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 433, in render_tag_if return self.render_element(element, template_attributes, generated_attributes, qwebcontext) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 323, in render_element g_inner.append(self.render_node(current_node, qwebcontext)) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 285, in render_node for att, val in attrs: File "/home/odoo8dev/git/odoo/addons/website/models/ir_qweb.py", line 61, in render_att_att for att, val in super(QWeb, self).render_att_att(element, attribute_name, attribute_value, qwebcontext): File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 359, in render_att_att return [(attribute_name[6:], self.eval(attribute_value, qwebcontext))] File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 207, in eval raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 204, in eval return qwebcontext.safe_eval(expr) File "/home/odoo8dev/git/odoo/openerp/addons/base/ir/ir_qweb.py", line 89, in safe_eval return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True) File "/home/odoo8dev/git/odoo/openerp/tools/safe_eval.py", line 314, in safe_eval return eval(c, globals_dict, locals_dict) File "", line 1, in QWebException: "tuple index out of range" while evaluating "website.image_url(lg[2], 'flag_image')"

mcassuto commented 8 years ago

@OpenSur: i would be happy to upvote on the appstore if fixed !