Skip to Content
Menu
This question has been flagged
2 Replies
9668 Views

Hi guys,

I purchased a module from Odoo Apps website which compatible with Odoo CE version 12.

Now i', planing to upgrade it to Odoo CE version 13 and i'm facing with an error like that:

ImportError: cannot import name 'binary_content' from 'odoo.addons.web.controllers.main' (e:\odoo\homing_missile13\addons\web\controllers\main.py)

Traceback (most recent call last):

  File "E:\Odoo\homing_missile13\odoo\http.py", line 624, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "E:\Odoo\homing_missile13\odoo\http.py", line 310, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "E:\Odoo\homing_missile13\odoo\tools\pycompat.py", line 14, in reraise

    raise value

  File "E:\Odoo\homing_missile13\odoo\http.py", line 669, in dispatch

    result = self._call_function(**self.params)

  File "E:\Odoo\homing_missile13\odoo\http.py", line 350, in _call_function

    return checked_call(self.db, args, *kwargs)

  File "E:\Odoo\homing_missile13\odoo\service\model.py", line 93, in wrapper

    return f(dbname, args, *kwargs)

  File "E:\Odoo\homing_missile13\odoo\http.py", line 339, in checked_call

    result = self.endpoint(*a, **kw)

  File "E:\Odoo\homing_missile13\odoo\http.py", line 915, in _call_

    return self.method(*args, **kw)

  File "E:\Odoo\homing_missile13\odoo\http.py", line 515, in response_wrap

    response = f(*args, **kw)

  File "e:\odoo\homing_missile13\addons\web\controllers\main.py", line 1326, in call_button

    action = self._call_kw(model, method, args, kwargs)

  File "e:\odoo\homing_missile13\addons\web\controllers\main.py", line 1314, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "E:\Odoo\homing_missile13\odoo\api.py", line 387, in call_kw

    result = _call_kw_multi(method, model, args, kwargs)

  File "E:\Odoo\homing_missile13\odoo\api.py", line 374, in _call_kw_multi

    result = method(recs, args, *kwargs)

  File "<decorator-gen-60>", line 2, in button_immediate_install

  File "E:\Odoo\homing_missile13\odoo\addons\base\models\ir_module.py", line 72, in check_and_log

    return method(self, args, *kwargs)

  File "E:\Odoo\homing_missile13\odoo\addons\base\models\ir_module.py", line 463, in button_immediate_install

    return self._button_immediate_function(type(self).button_install)

  File "E:\Odoo\homing_missile13\odoo\addons\base\models\ir_module.py", line 573, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "E:\Odoo\homing_missile13\odoo\modules\registry.py", line 86, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "E:\Odoo\homing_missile13\odoo\modules\loading.py", line 423, in load_modules

    loaded_modules, update_module, models_to_check)

  File "E:\Odoo\homing_missile13\odoo\modules\loading.py", line 315, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "E:\Odoo\homing_missile13\odoo\modules\loading.py", line 182, in load_module_graph

    load_openerp_module(package.name)

  File "E:\Odoo\homing_missile13\odoo\modules\module.py", line 382, in load_openerp_module

    __import__('odoo.addons.' + module_name)

  File "e:\odoo\homing_missile13\custom_addons\sync_documents\__init__.py", line 5, in <module>

    from . import controllers

  File "e:\odoo\homing_missile13\custom_addons\sync_documents\controllers\__init__.py", line 4, in <module>

    from . import main

  File "e:\odoo\homing_missile13\custom_addons\sync_documents\controllers\main.py", line 9, in <module>

    from odoo.addons.web.controllers.main import binary_content

ImportError: cannot import name 'binary_content' from 'odoo.addons.web.controllers.main' (e:\odoo\homing_missile13\addons\web\controllers\main.py).


By looking at the code i saw the file main.py has some code which is obsoleted (i reckon) in version 13 >

from odoo.addons.web.controllers.main import binary_content
from odoo.addons.http_routing.models.ir_http import slug

So can you help me guys?
What the replacement of binary_content is in Odoo CE version 13?

The same question with slug.

Apart from that, Pycharm also shows the errors at odoo.addons.web and odoo.addons.http_routing.

Any helps are much appriciated.

Thank you

Avatar
Discard
Best Answer

Hi,

Instead of importing the binary_content , you can get it like this,

request.env['ir.http'].sudo().binary_content

See a use case in V13:

status, headers, _content = request.env['ir.http'].sudo().binary_content(
model='res.partner', id=partner_id, field='image_128', default_mimetype='image/png')


Regarding slug you can import as it, you can see a lot of import in different modules.


from odoo.addons.http_routing.models.ir_http import slug


Thanks

Avatar
Discard
Author Best Answer

Thank you Niyas Raphy

It's working like a charm.

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 24
433
0
Dec 20
891
2
Dec 23
24066
0
Mar 15
3087
1
Mar 15
2499